Skip to content

timezone issue #2542

Closed
Closed

Description

@PavloPoliakov

Hi,

My local machine timezone is UTC+2.

When I do the next:

                   console.log(new Date());
                   reply(new Date());

Which leads to:

  1. in the console I see Wed May 20 2015 15:12:29 GMT+0200 (CEST)
  2. in the browser I see 2015-05-20T13:12:29.104Z

how to make them equal? haven't find any documentation reference.

Activity

  1. PavloPoliakov commented on May 20, 2015

    @PavloPoliakov
    Author

    I found only one line in hapijs, which looks like the one who does that convertion:

    hapi/node_modules/qs/lib/stringify.js:29
    

    But it seems that hapi doesn't reach that point while processing the reply.

    Any other thoughts?

  2. AdriVanHoudt commented on May 20, 2015

    @AdriVanHoudt
    Contributor

    they are the same dates.
    First one is gmt +2, so distract the 2 hours and the date is the same since date 2 is gmt +0

  3. PavloPoliakov commented on May 20, 2015

    @PavloPoliakov
    Author

    Well, they are the same.

    But we do not expect that one string would be shaped to the other string, in the reply method.

    Are there any ways to avoid it?

  4. AdriVanHoudt commented on May 20, 2015

    @AdriVanHoudt
    Contributor

    Since you pass the Date as a string to the browser I suggest to wrap incoming dates with new Date() so it's a date object again, same other way around, if the browser sends dates to the server, although that might be solvable with Joi

  5. PavloPoliakov commented on May 20, 2015

    @PavloPoliakov
    Author

    The full story is this:
    0. The timezone on the server is +2

    1. In the database we have the next value 2015-04-18 00:00:00 , TIMESTAMP.
    2. When we read the value from the database, using sequelize, we receive Sat Apr 18 2015 00:00:00 GMT+0200 (CEST) . It converts it to the date object.
    3. When we reply, with hapi, we receive 2015-04-17T22:00:00.000Z, string. Which doesn't correspond the value in the database.

    What we want to get - receive the same data in the front-end as it is stored in the database.
    And, if possible - avoid the duplicate conversion in the controller/model on the back-end side. E.g. - convert the Date to simple string, so hapi would not adjust it.

  6. AdriVanHoudt commented on May 20, 2015

    @AdriVanHoudt
    Contributor

    Isn't that sequalize adding the GMT +2 there? And then when turning that
    into Zulu that's correct so if the db stores as Zulu sequalize is doing
    something wrong

    On Wed, 20 May 2015 22:15 Pavel [email protected] wrote:

    The full story is this:
    0. The timezone on the server is +2

    1. In the database we have the next value 2015-04-18 00:00:00 , TIMESTAMP.
    2. When we read the value from the database, using sequelize, we receive Sat
      Apr 18 2015 00:00:00 GMT+0200 (CEST) . It converts it to the date object.
    3. When we reply, with hapi, we receive 2015-04-17T22:00:00.000Z, string.
      Which doesn't correspond the value in the database.

    What we want to get - receive the same data in the front-end as it is
    stored in the database.
    And, if possible - avoid the duplicate conversion in the controller/model
    on the back-end side. E.g. - convert the Date to simple string, so hapi
    would not adjust it.

    —
    Reply to this email directly or view it on GitHub
    #2542 (comment).

  7. PavloPoliakov commented on May 20, 2015

    @PavloPoliakov
    Author

    yep,

    It turned out that this is the sequelize issue. Which is nor bug nor feature.
    Here is the solution:
    sequelize/sequelize#3768 (comment)

    I suppose it would help, would try tomorrow morning.

  8. hueniverse commented on May 21, 2015

    @hueniverse
    Contributor

    hapi just called JSON.stringify() on the provided object. I don't know what console.log() does. If you want more control over the format you need to do it yourself and pass a string to reply().

  9. added
    non issue
    on May 21, 2015
  10. self-assigned this
    on May 21, 2015
  11. locked as resolved and limited conversation to collaborators on Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

non issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions