Answer the question
In order to leave comments, you need to log in
How to fix time in javascript if user in system has wrong date?
Hi friends, I use the moment library to display the last user actions using the method moment(date).fromNow()
, it looks like this: a
minute ago
5 minutes ago
And if the user does not have the correct time, then moment can display the following text:
in
14 minutes
in 19 minutes
then fix the local time in the browser?
Answer the question
In order to leave comments, you need to log in
Obviously, either transmit the already processed time from the server (that is, in text, for example), or transmit the page opening time from the server, on the client, when loading, count the difference between the client and the server and compensate for this difference with each time output.
In moment, you can even override the current time and simply make it equal to the server time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question