on 17/03/03 11:55 PM, M Wells ([EMAIL PROTECTED]) wrote:

> I'm an Australian PHP developer and host most of my web sites on US
> servers. One in particular is primarily accessed by Australian visitors
> and I want to be able to reflect Australian Eastern Standard Times when
> writing / reporting records, rather than the server time, which is set
> to US Eastern Standard Time.
> 
> I'm wondering if anyone can tell me if there is a sensible way to do
> this easily?

I'm also an Australian developer, with many many sites hosted in the US.

My base library of code includes a config file, which amongst many things,
has a setting for a time difference (14 hours).  I'm not picky enough to be
worried about daylight savings though (given that most of Australia has
different start/end dates to begin with).

I choose to store all dates in my MySQL database using unix timestamps
(seconds since 1970), so, 60 sec x 60 min x 14 hrs = 50400 seconds behind.


To get the current time (untested):

<?
$cfg_time_difference = 50400;
$date = date('Y-M-D h:m:s',time() + $cfg_time_difference);
echo "the current time in Australia is {$date}";
?>

I tend to insert all dates into MySQl in GMT, then add the time difference
to the time after I query the database, so I wrote a small function which
formats all my timestamps for me, site wide, as I pull them out of the
database, to my chosen format (eg 'Y-M-D h:m:s'), with the adjustment.

That's enough typing for today :)


Justin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to