L
L
lavezzi12018-11-07 07:18:18
MySQL
lavezzi1, 2018-11-07 07:18:18

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

2 answer(s)
R
Ruslan Fedoseev, 2018-11-07
@lavezzi1

Check the time zones in the settings of the server and your applications

A
Alexey Laud, 2018-11-07
@kshshe

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 question

Ask a Question

731 491 924 answers to any question