#1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    You know the timezone offset in PHP? Well my web server is in Texas and I am in the UK, so I want to get the local UK time from a PHP script, not the Texas time. Is there any way to do this, perhaps using the offset feature in PHP's time function? I need some code for this by the way!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    32
    Rep Power
    15
    If you know how many hours your server is to where u live.. you can always add or subtract from the time().

    There's also gmdate() that gives you the date and time from GMT.. similarly with gmmktime for the unix timestamp in GMT.

    scoobydoo
  4. #3
  5. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    I can figure out the hours by running the Date/Time function on my server, then looking at the local time. It's 5 hours behind me. So how do I make the time 5 hours less?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    32
    Rep Power
    15
    When you use time(), it returns you with a timestamp, and that's in seconds, so,

    5 hours behind is,
    5 hrs x 60 mins x 60 secs = 18000 secs...

    Just minus that from the time()

    eg.

    $time_diff = 18000;
    $server_time = time();
    $local_time = $server_time - $time_diff;

    That's how I do it.. I think that's the correct way =)

    scoobydoo
  8. #5
  9. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    actually you'd want to ADD 18000 going from central to GMT. Unfortunately, this will only work until DST ends, in which case the difference will be 6 hours. Check the manual, there is a way to tell if DST is active or not so that if it is you add 5 hours and if it isn't you add 6.

Similar Threads

  1. OFFSET and subselects
    By glwtta in forum PostgreSQL Help
    Replies: 2
    Last Post: November 22nd, 2003, 12:22 AM
  2. comapring database time and computer date/time
    By icepricessa in forum ASP Programming
    Replies: 2
    Last Post: September 10th, 2003, 08:59 AM
  3. Storing date/time as filenames
    By vb.net in forum Perl Programming
    Replies: 4
    Last Post: June 5th, 2003, 08:32 PM
  4. How to retrieve offset to particular row?
    By Ahriman in forum MySQL Help
    Replies: 1
    Last Post: April 12th, 2002, 03:17 AM
  5. Undefined offset error
    By HannahD in forum PHP Development
    Replies: 27
    Last Post: December 7th, 2001, 08:19 AM

IMN logo majestic logo threadwatch logo seochat tools logo