Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server there, store here; output store dates with daylight saving time

Status
Not open for further replies.

superslurpee

Programmer
Joined
May 15, 2002
Messages
108
Hi,

I'm having a bit of trouble with dates. My server is at GMT while my store is in the central time zone in Canada. During daylight savings time, we are GMT-5 and GMT-6 when not.

How do I account for these changes when outputting the date and time? I was just hardcoding a subtraction of 5 or 6 hours but this hardly practical.

Any help is appreciated!
 
Can you explain a little more what your trying to do, I am a little confused.

___________________________________
[morse]--... ...--[/morse], Eric.
 
Thats quite and interesting, if fluffy, article DRJ. What would be great is if you could send up the TZ with browser request, I'm sure a bit of Javascript would fit the bill.
I assume on the article they require the portal user to register a timezone.
I have a server in the USA and I'm in the UK and I'm convincedthat the remote server condered GMT as its own local time !
 
Hi,

Thanks for your posts but I'm still a bit confused.

I'll explain a bit more. My server is in the UK and uses GMT. That is, if it's 19:55 GMT, my server's localtime is 19:55 (the same). I am in Canada where we observe daylight saving (we are right now). So right now, our time is 14:55 or GMT-5. I have just been hardcoding the server's time minus 5 hours to display the store's time (here in Canada).

Now in the fall when daylight saving time ends, we become GMT-6. That is, the time would be 13:55. A hardcoded subtraction of 5 hours does not work anymore.

How can I account for this time change? In many of the articles I read, the server isn't using GMT but mine is. This is driving me batty!

Thanks for any help! :)
 
What about this:
Code:
print "<pre>";
# show current time zone
print("Server timezone is: " . getenv('TZ') . "<br />\n");
print("Server time is: " . date("H:i:s") . "<br />\n");
# change
putenv("TZ=US/Eastern");
print_r(localtime(time(),1));
print("New timezone is: " . getenv('TZ') . "<br />\n");
print("New time is: " . date("H:i:s") . "<br />\n");
Let's see if that does it!
 
Hi,

I really appreciate your help with this! I think what you suggested is on the right track but when I output the code you provided on my server at GMT I get this:

Code:
Server timezone is:
Server time is: 08:43:22
ArrayNew timezone is: US/Eastern
New time is: 04:43:22

The getenv('TZ') function doesn't seem to return anything. I tried various ways and it was always empty. The print_r(localtime(time(),1)); line writes out 'Array'.

Any thoughts on this matter are appreciated!
 
Can you telet to the server ?,if you can do an env and post the results
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top