Skip to content

Instantly share code, notes, and snippets.

@PankajWorks
Last active March 2, 2017 10:11
Show Gist options
  • Save PankajWorks/08e23228e7352a0b892a214f240641b9 to your computer and use it in GitHub Desktop.
Save PankajWorks/08e23228e7352a0b892a214f240641b9 to your computer and use it in GitHub Desktop.
Ember - How to update date time - Example
// Sample handelbar code <h5> Current System Date- {{utctime}} (UTC)</h5>
import Ember from 'ember';
import config from './../config/environment';
export default Ember.Route.extend({
query: 'from_unixtime(start_time)>=curdate() and from_unixtime(start_time)<=DATE_ADD(curdate(),INTERVAL+1 day)',
model() {
var store = this.store;
return Ember.RSVP.hash({
todayruns: Ember.$.ajax({ url: config.server_host + '/' + config.api + '/runs?query=' + this.get('query'), dataType: "json", type: 'GET' }),
});
},
setupController(controller, model) {
this._super(controller, model);
this.startWatchingTime(controller);
controller.set('todayruns', model.todayruns);
},
startWatchingTime: function(controller){
var self = this;
controller.set('utctime', moment.utc().format('YYYY-MM-DD HH:mm:ss'));
Ember.run.later(function(){
self.startWatchingTime(controller);
}, 1000);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment