June 15th, 2000, 08:34 AM
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!
June 16th, 2000, 04:50 AM
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.
June 16th, 2000, 06:33 AM
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?
June 16th, 2000, 11:25 AM
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()
$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 =)
June 16th, 2000, 12:44 PM
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.