note 96450 added to function.strtotime

From: Date: Sat, 27 Feb 2010 18:06:16 +0000
Subject: note 96450 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-166437@lists.php.net to get a copy of this message
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! ---- Server IP: 69.147.83.197 Probable Submitter: 178.38.38.218 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/96450 Del: integrated -- https://master.php.net/note/delete/96450/integrated Del: useless -- https://master.php.net/note/delete/96450/useless Del: bad code -- https://master.php.net/note/delete/96450/bad+code Del: spam -- https://master.php.net/note/delete/96450/spam Del: non-english -- https://master.php.net/note/delete/96450/non-english Del: in docs -- https://master.php.net/note/delete/96450/in+docs Del: other reasons-- https://master.php.net/note/delete/96450 Reject -- https://master.php.net/note/reject/96450 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166437) next »