I have sails.js application.
When I add record to my MySQL database there is field createdAt - type dateTime.
In MySql console createdAt value looks like Wed Mar 25 2015 00:00:00 GMT+0100
When I try to get this data as JSON using sails.js controller I get
2015-03-24T23:00:00.000Z
- which is 1 hour elier?
My system time zone is GMT +1.
How can I get the same time in db and JSON rsponse?
'list': function (req, res, next) {
Tests.find().exec(function (err, tests) {
if (err) res.json({ error: 'DB error' }, 500);
if (tests) {
_.each(tests, function (data) {
console.log("Date: " + JSON.stringify(data.createdAt)+" "+data.createdAt);
})
res.status(200).json(tests);
}
});
And console output is:
Date: "2015-03-10T14:28:51.000Z" Tue Mar 10 2015 15:28:51 GMT+0100
Date: "2015-03-16T10:25:34.000Z" Mon Mar 16 2015 11:25:34 GMT+0100
Date: "2015-03-16T11:27:23.000Z" Mon Mar 16 2015 12:27:23 GMT+0100
Date: "2015-03-16T11:33:39.000Z" Mon Mar 16 2015 12:33:39 GMT+0100
Date: "2015-03-16T11:34:41.000Z" Mon Mar 16 2015 12:34:41 GMT+0100
Date: "2015-03-16T12:13:21.000Z" Mon Mar 16 2015 13:13:21 GMT+0100
Date: "2015-03-16T13:54:03.000Z" Mon Mar 16 2015 14:54:03 GMT+0100
It all happends while converting to JSON - still dont know how to fix it.