The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Date/Time offset
Discuss Date/Time offset in the PHP Development forum on Dev Shed. Date/Time offset PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 15th, 2000, 07:34 AM
|
 |
Full Access
|
|
Join Date: Jun 2000
Location: London, UK
Posts: 2,019
Time spent in forums: 3 sec
Reputation Power: 15
|
|
|
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, 03:50 AM
|
|
Contributing User
|
|
Join Date: Jun 2000
Location: Sydney, Australia
Posts: 32
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
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
|

June 16th, 2000, 05:33 AM
|
 |
Full Access
|
|
Join Date: Jun 2000
Location: London, UK
Posts: 2,019
Time spent in forums: 3 sec
Reputation Power: 15
|
|
|
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, 10:25 AM
|
|
Contributing User
|
|
Join Date: Jun 2000
Location: Sydney, Australia
Posts: 32
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
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
|

June 16th, 2000, 11:44 AM
|
|
Apprentice Deity
|
|
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237

Time spent in forums: 4 m 8 sec
Reputation Power: 17
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|