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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Can I Modify This To Set Correct Time Zone?

Status
Not open for further replies.

jeff35080

IS-IT--Management
Joined
May 19, 2004
Messages
1
Location
US
Howdy! I'm hoping someone can help me with this tidbit of php code that is driving me bonkers. Basically the server where this code (and mysql db) resides is in CA and my users are in the Central time zone, thus the time stamps they see aren't correct. How can I change this code to add two-hours? I have played around with it but just can't seem to get it to do what I need it to do. Here's the code snippet and thanks in advance for any and all help!

Code:
// date("O"); = difference to GMT. Example: +0800

	$sql = "select * from ".$prefix."_shoutbox_date";
	$resultD = $db->sql_query($sql);
	$rowD = $db->sql_fetchrow($resultD);
	$day = date("$rowD[1]");
	$time = date("$rowD[2]");
 
Assuming you can get it to a PHP/Unix timestamp, just add 7200 to the timestamp (# of seconds in 2 hours).

Now mind you, this isn't the most elegant solution, but it is a direct answer to the question. If you really want to handle multiple timezones well, I'd suggest using GMTimes and the accompanying GMTime/Date functions.... this will let you account for things like Daylight savings times in the US and whatever it is they call it in the UK being several weeks apart and the like.

-Rob

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top