When I create a model object via rest the model has following fields.
"createdAt": "2013-10-09T19:13:43.299Z",
"updatedAt": "2013-10-09T19:13:43.299Z",
Why is this Zulu time? I need GMT+2. Is there a chance to setup this?
Most databases store in zulu time so you can do adjustment locally with the data. This is for normalization. These following links show how to adjust dates in database/zulu format to local time.
Basic example -> http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp
More likely to help -> http://stackoverflow.com/questions/8602047/change-the-javascripts-gettimezoneoffset-to-return-a-different-time-zone-offset
@reecelewellen Hm I use mongodb and I think it has no knowing about timezone. However I found
process.env.TZ = "GMT+2"
where should I put it?
you would want to use app.set('tz', 'GMT+2')
That is the express way. I just need to remember where you put that in express --thinks--
Oh! https://gist.github.com/mikermcneil/6255295. So per the example:
// this goes in config/express.js, again per example.
module.exports.express = {
setTimeZone: function (app) {
app.set('tz', 'GMT+2');
}
};
At least I believe you want to use app.set('tz') per http://expressjs.com/api.html#app.configure
@reecelewellen ohm there is no express.js file in config folder, can I just create it? I use sails 0.9.4
Indeed, very few people need custom express middleware so they do not add it. SailsJS is just so impressive ;)
@reecelewellen hm not working. When I lift my sails project:
debug: :: Wed Oct 09 2013 22:46:08 GMT+0200 (CEST)
however in database it get stored in zulu.
That would be a waterline bug then. Waterline should store in the database off the app's timezone. ( @particlebanana , @sgress454 , @mikermcneil )
You should close this, and open a new issue here. https://github.com/balderdashy/waterline
As, you can see I tagged some of the main folks so even outside of your new issue they will get the update.
(PS I am glad to see your app.set('tz') middleware worked! How exciting! One step closer to the correct db insert!)
hi. I solved the problem, you should setting the MySql options file to change timezone to UTC
in the config/connections.js
setting at this
devMysqlServer: {
adapter: 'sails-mysql',
host: '127.0.0.1',
user: 'root',
password: '***',
database: '**',
timezone: 'utc'
},
Most helpful comment
hi. I solved the problem, you should setting the MySql options file to change timezone to UTC
in the config/connections.js
setting at this