Skip to content

Instantly share code, notes, and snippets.

@prestonp
Last active August 29, 2015 13:57
Show Gist options
  • Save prestonp/9535819 to your computer and use it in GitHub Desktop.
Save prestonp/9535819 to your computer and use it in GitHub Desktop.
unexepected timestamp handling
var models = require('./models');
var utils = require('./utils');
var config = require('./config');

models.Order.find({}, function(err, results) {
  console.log('models.Order.find type of datetime',results[0].attributes.datetime);
  console.log('type of datetime', typeof results[0].attributes.datetime);
});


var query = {
  updates: {
    edit_token: utils.uuid.v4()
  , edit_token_expires: moment().add('days', config.expires.shareLink).format('YYYY-MM-DD HH:mm:ss')
  }
, where: {
    id: 909
  }
};
models.Order.update(query, function(err, results) {
  console.log('models.Order.update',results[0].attributes.datetime);
  console.log('type of datetime', typeof results[0].attributes.datetime);
});

Prints

models.Order.update Fri Mar 14 2014 16:30:00 GMT-0500 (CDT)
type of datetime object
models.Order.find type of datetime 2014-03-14 12:15:00
type of datetime string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment