I’m simply trying to display my local time in Miami using the following code:
date_default_timezone_set('America/New_York'); //is added in library
$timestamp = time();
$timezone = 'UM5'; //(UTC - 5:00) Eastern Time, Bogota, Lima, Quito
$daylight_saving = TRUE;
$miamitime = gmt_to_local($timestamp, $timezone, $daylight_saving);
echo unix_to_human($miamitime); // U.S. time, no seconds
The time I’m getting is 1 day ahead and 1 hour behind the actual local time. I’m testing the site on local server using WAMP (not sure if that’s causing the issue). It looks to me like I’m setting everything right.. I’m not sure what is causing this. Please advise how to correctly display my local time.
Inside your htaccess file you can insert this (right at the very top of the file)
It will force your server to be set to whatever timezone you want. Good for hosted solutions when the local time of the server is not actually “your” local time.