current position:Home>The database function queries the MySQL database at the correct time

The database function queries the MySQL database at the correct time

2022-05-15 05:14:08houxian1103

problem :

When using database functions , Use select *,FROM_UNIXTIME(create_date/1000,'%Y-%m-%d') times, When calculating the timestamp , Obviously 05-13 date , I don't know why the query is always 05-12, So it's strange , The time stamp is calculated normally, but it does , see linux The time on the is also correct .

Solution :

A temporary plan :
set global time_zone=‘+08:00’;
set time_zone=‘+08:00’;
Permanent solution
stay mysql Modify on the database machine ,/etc/my.cnf
default-time-zone=‘+08:00’
restart mysql service , Make settings effective :
service mysqld restart

copyright notice
author[houxian1103],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/135/202205142227351967.html

Random recommended