|
-
Jun 28th, 2005, 06:35 AM
#1
Thread Starter
Ex-Super Mod'rater
Daylight saving
Whats the best way to adjust times to acount for daylight saving. Is there any built in functions or do I have to manually work it out?
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Jun 28th, 2005, 04:41 PM
#2
Re: Daylight saving
Usually the operating system takes care of this. However, you can use both the date() and localtime() functions to find otu whether or not daylight savings time is in effect.
-
Jun 29th, 2005, 09:34 AM
#3
Thread Starter
Ex-Super Mod'rater
Re: Daylight saving
Problem is though the server is if the server is in the US and the time I'm after is british time then the server won't adjust for daylight saving at the right time.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Jun 29th, 2005, 10:27 AM
#4
Fanatic Member
Re: Daylight saving
i dont beleive there is a way to ask the client for the time. if they stated that they were (lets say) 4 hours difference, you could eassily do it:
http://us3.php.net/localtime (there are examples in there)
-
Jun 29th, 2005, 11:20 AM
#5
Thread Starter
Ex-Super Mod'rater
Re: Daylight saving
 Originally Posted by ALL
i dont beleive there is a way to ask the client for the time. if they stated that they were (lets say) 4 hours difference, you could eassily do it:
http://us3.php.net/localtime (there are examples in there)
No if I use localtime() it will adjust for daylight savings based on when the US implement it, because thats where the server is. I guess I'll just have to put up with that as I expect most my customers will have UK based servers, even though my demo server is US based .
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Jun 29th, 2005, 02:16 PM
#6
Re: Daylight saving
Like the forum software, you could ask the user to specify their timezone offset and ask them whether they have daylight savings time in their country. You can also use gmdate() function to return the GMT time which will be calculated using the servers timezone offset.
You can also use the date function to find the offsaet from GMT in seconds. Combined with the offset for the current locale (e.g GMT+2hours) you can calculate the timestamp for the client based on that:
PHP Code:
$server_gmtoffset = (int) date('Z');
$local_offset = 2; //in hours
$localtime = time() - $server_gmtoffset - ($local_offset * 60 * 60);
-
Jun 29th, 2005, 05:57 PM
#7
Re: Daylight saving
Use setlocale() and hope the locale is installed on the target server:
PHP Code:
<?php
setlocale("de-AT"); // Set locale to German, Austria
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|