I'm attempting to set a static time zone to a date for HST (Hawaii time) so no matter where you are in the world it shows the time in Hawaii. Here is my code.
ini_set('date.timezone', 'Pacific/Honolulu');
echo date("m/d/Y g:i a");
echos out 09/03/2014 3:14 pm which is EST time.
I want it to echo out 09/03/2014 9:14 am
Your host may not support ini_set()
. You can overcome this by using date_default_timezone_set()
.
date_default_timezone_set('Pacific/Honolulu');
echo date("m/d/Y g:i a");
You can also use DateTime()
with DateTimeZone()
.
$date = new DateTime();
$date->setTimezone(new DateTimeZone('Pacific/Honolulu'))
echo $date->format("m/d/Y g:i a");