The time when node mysql is stored in the database is inconsistent with the time it takes to get to the front end. How to solve this problem?

above:

this is the time in the database
clipboard.png

clipboard.png

sql
clipboard.png

(?)

 

in addition, my mysql uses the mysql database of esayPHP linked by navicat, and the local computer does not have a mysql database. Will this also have an impact?

Apr.01,2021

if the driver you are using is mysql , modify the option parameters when creating a DB connection by adding dateStrings: true


time, but the front end sees a UTC time (with time zone), you can add 8 hours (if it is China), or use moment.js to convert it to your preferred format.


mysqljs document
has a timezone option to set the time zone when configuring the connection.
or configure dateStrings option to true , do not convert to Date and only return strings.

Menu