PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 15th, 2000, 07:34 AM
alexgreg's Avatar
alexgreg alexgreg is offline
Full Access
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jun 2000
Location: London, UK
Posts: 2,019 alexgreg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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!

Reply With Quote
  #2  
Old June 16th, 2000, 03:50 AM
scoobydoo scoobydoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Sydney, Australia
Posts: 32 scoobydoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #3  
Old June 16th, 2000, 05:33 AM
alexgreg's Avatar
alexgreg alexgreg is offline
Full Access
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jun 2000
Location: London, UK
Posts: 2,019 alexgreg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #4  
Old June 16th, 2000, 10:25 AM
scoobydoo scoobydoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Sydney, Australia
Posts: 32 scoobydoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #5  
Old June 16th, 2000, 11:44 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Date/Time offset

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap