Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different timestamp created by node.js and browser #9805

Closed
EasonWang01 opened this issue Nov 26, 2016 · 8 comments
Closed

Different timestamp created by node.js and browser #9805

EasonWang01 opened this issue Nov 26, 2016 · 8 comments

Comments

@EasonWang01
Copy link

EasonWang01 commented Nov 26, 2016

  • 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?

@addaleax
Copy link
Member

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

@EasonWang01
Copy link
Author

EasonWang01 commented Nov 26, 2016

2016-11-26 3 41 26

the node one is 07:xx:xx

but browser is 15:xx:xx

@addaleax
Copy link
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.

@EasonWang01
Copy link
Author

sorry about that,another stupid question.

@addaleax
Copy link
Member

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

@Pustur
Copy link

Pustur commented Dec 12, 2016

@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

@addaleax
Copy link
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. :)

@haffedali
Copy link

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants