Wade Smart wrote: > 20080619 1605 GMT-6 > The time zone on a shared server Im working on is two hours behind where Im > located. I found the php function to change it but Im not understanding it.
I use the function MakeTime below to dynamically change the timezone per script run. This has the advantage of not needing to mess with the server configuration. One thing to note about the function, it gets the GMT date from the current server time and time zone setting. So if this is not correct you will have to adjust the value you pass to the function accordingly. Example use for time zone +5 GMT: echo MakeTime("+","5","true","Y-m-d H:i:s"); function MakeTime($sign,$h,$dst,$format) { // Get info about time zone relationship to GMT at: http://wwp.greenwichmeantime.com/ // SELECT TIME ZONE //$sign = "-"; // Whichever direction from GMT to your timezone. //$h = "8"; // Hour for time zone goes here e.g. +8 or -4, just remove the + or - //$dst = "true"; // Just insert "true" if your location uses daylight savings time or "false" if it does not // DETECT AND ADJUST FOR DAYLIGHT SAVINGS TIME if ($dst) { $daylight_saving = date('I'); if ($daylight_saving) { if ($sign == "-") $h=$h-1; else $h=$h+1; } } // FIND DIFFERENCE FROM GMT $hm = $h * 60; $ms = $hm * 60; // SET CURRENT TIME if ($sign == "-") $timestamp = time()-($ms); else $timestamp = time()+($ms); $gmdate = gmdate("$format", $timestamp); return $gmdate; }