On 31/01/2012 01:55, Ron Piggott wrote:
>
> On my clients account when I use “echo date(‘D, d M Y H:i:s');” the output is
> 5 hours ahead of us. How do I change it to my local time? Is there a way to
> specify “Eastern” time zone?
>
> I expect this would work:
>
> echo date(‘D, d M Y H:i:s' , ( strtotime( date(‘D, d M Y H:i:s') – 21600 ) )
> );
>
> I would prefer to specify Eastern time, so if the web host changes a server
> setting it will remain in Eastern time zone. Ron
Hi Ron,
I use this function to get the current time in a particular timezone:
<?php
/**
* Return the current local time by timezone name
* @param string $timezone
* @return array
* @author Ian Gibbons
*/
function getNowByTimezone($timezone){
$remote_timezone= new DateTimeZone($timezone);
$remote_time = new DateTime("now", $remote_timezone);
return getDate(strtotime($remote_time->format("Y-m-d H:i:s")));
}
?>
Example:
<?
$london_time = getNowByTimezone("Europe/London");
echo date("D, d M Y H:i:s", $london_time[0]);
?>
Regards
Ian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php