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

new Date gives wrong datetime by ~17 seconds compared to system time #2375

Closed
cjh9 opened this issue Dec 28, 2019 · 6 comments
Closed

new Date gives wrong datetime by ~17 seconds compared to system time #2375

cjh9 opened this issue Dec 28, 2019 · 6 comments

Comments

@cjh9
Copy link

cjh9 commented Dec 28, 2019

  • Version:
    node -v v13.5.0

  • Platform:
    Ubuntu 18.04.3 LTS (Digital ocean server)
    4.15.0-70-generic Mani node#79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Ssh:ing in having two terminal windows open simultaneously, opening node in one:

sudo hwclock --show
2019-12-28 21:26:50.403548+0000

(this is the correct time)

In node:

new Date
2019-12-28T21:26:33.216Z

Seems to be lagging behind by 18 seconds?

@addaleax
Copy link
Member

What does date show in the terminal? Does it match hwclock or Node.js?

@cjh9
Copy link
Author

cjh9 commented Dec 28, 2019

Sorry, seems that date shows Sat Dec 28 21:35:57 UTC 2019 and
new Date 2019-12-28T21:35:57.772Z. Seems to be problems at ubuntu then?

@addaleax
Copy link
Member

@cjh9 Yes, I would guess it’s an issue with your system’s setup, in some way.

@addaleax addaleax transferred this issue from nodejs/node Dec 28, 2019
@bnoordhuis
Copy link
Member

@cjh9 What you're seeing is not unexpected. Most hardware clocks have considerable drift, they gain or lose time over, er, time.

The operating system normally adjusts the reported time automatically, that's probably why you're seeing a discrepancy between the two.

Try installing ntpdate(1), that should keep them in sync (mostly - they might still disagree by a few seconds every once in a while until they're synchronized again.)

@PoojaDurgad
Copy link

ping - @cjh9 , is this still an issue?

@PoojaDurgad
Copy link

inactive. closing!!

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