Skip to content

Time zone is double-shifted when saving #303

Description

@dirkmc

Note that I ran this code at 19:21:01 EDT (New York time), which is 23:21:01 UTC (NY is four hours behind UTC). But when the value is stored to the database it has been shifted four hours again, to 03:21:01 UTC.

var now = new Date();
db.Test.create({
    created_at: now,
    mytext: 'test'
}, function(err, data) {
    db.Test.get(data.id, function(err, newObj) {
        console.log(JSON.stringify(now));
        // "2013-08-18T23:21:01.979Z"
        console.log(JSON.stringify(newObj.created_at));
        // "2013-08-19T03:21:01.000Z"
    });
});
mysql> select id, created_at, UNIX_TIMESTAMP(created_at) from test where id = 5;
+----+---------------------+----------------------------+
| id | created_at          | UNIX_TIMESTAMP(created_at) |
+----+---------------------+----------------------------+
|  5 | 2013-08-18 23:21:01 |                 1376882461 |
+----+---------------------+----------------------------+

Taking the unix timestamp value above and putting it into the browser console shows that it is 23:21:01 EDT (NY time) when it should be 19:21:01 EDT:

new Date(1376882461 * 1000);
Sun Aug 18 2013 23:21:01 GMT-0400 (EDT)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions