Results 1 to 3 of 3

Thread: TimeZone Offset

  1. #1
    Join Date
    Jul 2009
    Location
    London
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default TimeZone Offset

    I am trying to offset my timezone by 8 hours.
    I tried:
    PHP Code:
    var $offset ;                     
    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:
    PHP Code:
    var $now NOW(); 
    ...& it returned the same Error Message.

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Have you tried this code, I haven't tested it but it should work.

    PHP Code:
    $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.

  3. #3
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Try this:
    http://br.php.net/manual/en/function...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.
    - Josh

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •