note 96450 rejected from function.strtotime by danbrown

From: Date: Mon, 01 Mar 2010 16:04:20 +0000
Subject: note 96450 rejected from function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166508@lists.php.net to get a copy of this message
Note Submitter: avalerio at castor dot net ---- I need to calculate the difference between a start and end date in a given port city, which may be anywhere in the world. I'm using: $lObjStrtDt = strtotime($lStrtDt); $lObjEndDt = strtotime($lEndDt); // Calculate difference in seconds, and convert to hours. $lTotlTmUsed = ((($lObjEndDt - $lObjStrtDt) / 60) / 60); The problem is when the dates cross the date when daylight savings time (DST) changes. I need to take DST into account if it's on in the given city. Since DST is different around the world, I need be able to detect it by city. date_default_timezone_set() allows setting the time zone, but the parameter for this function (e.g., America/Vancouver) doesn't correspond to either Windows time zones (or any other that I know of). I could add a field to my Cities table to allow linking the city with these time zones, but that's not exactly user friendly, since it's my users that will be adding new cities.Any ideas for a simpler implementation that doesn't ask a user to choose "America/Vancouver"? IMO, someone should take a geography lesson!

« previous php.notes (#166508) next »