Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing MySQL timestamps in local time

I have a MySQL database with a lot of data stored with timestamps all in UTC time.

When a user queries that database, I want them to be able to view the data but in their local timezone.

I'd prefer not to have to calculate an offset each time and change the timestamp with PHP code. Is there any other way?

like image 894
bpmccain Avatar asked Oct 28 '25 02:10

bpmccain


1 Answers

You can use localtime() function to get the local time and find the matching records from database.

like image 140
Tarik Avatar answered Oct 30 '25 16:10

Tarik