Page 1 of 1

Retrieving MySQL timestamp value and displaying as localtime

Posted: Wed May 28, 2014 3:19 pm
by energylevel
How to output a MySQL UTC timestamp field to correct local time with daylight saving with PHP?

Local time is set in php.ini with: date.timezone = "Europe/London"

Confirmed set with: <?php echo date_default_timezone_get(); ?>

But when I echo the timestamp field it does not display correct UK time for the record (an hour behind correct UK time).

<?php echo date('jS F Y - g:ia', strtotime($row['Date'])); ?>

Re: Retrieving MySQL timestamp value and displaying as local

Posted: Wed May 28, 2014 4:20 pm
by requinix
MySQL handles the timezone conversion for TIMESTAMPs for you, but of course you have to set the right timezone for that to work properly.