Log in

View Full Version : TimeZone Offset



20pictures
08-03-2009, 08:49 AM
I am trying to offset my timezone by 8 hours.
I tried:


var $offset = 8 ;
var $now = DATE_ADD(NOW(),INTERVAL $offset HOUR);


...but I keep getting Error Message:
Parse error: syntax error, unexpected '(', expecting ',' or ';'

I've compared the syntax to various sources & it seems correct. Any ideas on what is wrong?

I even tried:


var $now = NOW();


...& it returned the same Error Message.

forum_amnesiac
08-06-2009, 01:29 PM
Have you tried this code, I haven't tested it but it should work.



$offset=8;

$time_there = time() + ($offset * 60 * 60);
$date_there_1=date("m:d:Y H:i",$time_there)

$date_there_2=date('m:d:Y H:i', strtotime('+'.$offset.' hour'));

You can use either $time_there_1 or $date_there_2 for the timezone 8 hours ahead.

JShor
08-10-2009, 02:18 PM
Try this:
http://br.php.net/manual/en/function.timezone-offset-get.php

You can offset the time by {x} hours automatically using that function by specifying which time zone the user [or you] are in.