Answer the question
In order to leave comments, you need to log in
How to synchronize time between backend and frontend?
Hello. Nodejs backend, mysql database. There is a message table, with a createdAt field of the timestamp type. There is a second table with the same field, it is necessary to record the last activity in it, such as when the last message was sent by the user, etc. The difference is that the message timestamp is written automatically in the table, and manually in the second table.
The problem is that in the message table the date is 2018-11-07 03:36:07, and in the second table it is 2018-11-07 11:36:07. When writing to the second table, I generate the
Backend in this way and the frontend is deployed on LAN. moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')
Answer the question
In order to leave comments, you need to log in
Check the time zones in the settings of the server and your applications
It is best to create such data on the backend. So there will be no time difference.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question