Skip to content

Different timestamp created by node.js and browser #9805

Description

@EasonWang01
  • Version: 7.0.0
  • Platform: mac
  • Subsystem:

new Date() function create different timestamp for nodejs runtime, the browser created is correct,what might cause this problem?

Activity

  1. addaleax commented on Nov 26, 2016

    @addaleax
    Member

    Could you please give an example of Node.js and browser output, to show what you think is wrong?

  2. EasonWang01 commented on Nov 26, 2016

    @EasonWang01
    Author

    2016-11-26 3 41 26

    the node one is 07:xx:xx

    but browser is 15:xx:xx

  3. addaleax commented on Nov 26, 2016

    @addaleax
    Member

    Those are the same date, just displayed differently. The Z in 2016-11-26T07:41:09.319Z stands for UTC+0, and you’re in UTC+8.

    You can check this by using new Date().toString() and new Date().toJSON(): Both of these will return the same value in Node.js and your browser.

  4. EasonWang01 commented on Nov 26, 2016

    @EasonWang01
    Author

    sorry about that,another stupid question.

  5. addaleax commented on Nov 26, 2016

    @addaleax
    Member

    @EasonWang01 Don’t worry about it, I’m glad I could help!

  6. Pustur commented on Dec 12, 2016

    @Pustur

    @addaleax: Hey there, i was wondering why the default format has been changed to an ISO string? Is there a reason?

    Just curious since it caused me some trouble that i wasn't expecting :P
    Thanks

  7. addaleax commented on Dec 12, 2016

    @addaleax
    Member

    @Pustur #4318 was the PR that changed that, you can follow the links/discussion there. Tbh, I find it a bit weird that the ISO representation is used as the more “human-readable” format (which is what util.inspect is supposed to show), but I am pretty sure you could have endless arguments about that. :)

  8. haffedali commented on Nov 6, 2019

    @haffedali

    @EasonWang01 > sorry about that,another stupid question.

    Not stupid at all! I was just thinking the world was upside down when I saw it logged to different formats! I'm happy I found your question, it was really educational for me

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions