RE: [PHP] Weird mktime problem

From: Date: Thu, 26 Jun 2003 09:52:58 +0000
Subject: RE: [PHP] Weird mktime problem
Groups: php.general 
Request: Send a blank email to php-general+get-152942@lists.php.net to get a copy of this message
> -----Original Message----- > From: Glenn [mailto:WaterDios@yahoo.com] > Sent: 25 June 2003 14:58 [....] > Here is what's weired. > > I use these lines to get the specifics: > $StartHour = substr("$StartTime", 0, 2); > $StartMinute = substr("$StartTime", 3, 2); > $EndHour = substr("$EndTime", 0, 2); > $EndMinute = substr("$EndTime", 3, 2); > list($SMonth, $SDay, $SYear) = split('/', $StartDate); > list($EMonth, $EDay, $EYear) = split('/', $EndDate); > > I then do this: > $SUnixTime = mktime($StartHour, $StartMinute, 00, $SMonth, > $SDay, $SYear); > > This is what's being sent to the mktime: > (17,00,00,06,23,2003) > > This is what it ouputs: > 1056405600 > > Which is not technically correct. That is the unix time stamp for the > starting our in Zulu time (greenwich mean time) which is > currently 5 hours > ahead of my timezone. > > Can anyone tell me why mktime is automatically converting to > zulu time? UNIX timestamps are *always* GMT -- it's the routines that process them that do timezone (and DST) conversion. To prove this, run the following on your server: <?php $timestamp = 1056405600; echo "GMT = ", gmdate("Y-m-d H:i:s"), "<br />\n"; echo "local = ", date("Y-m-d H:i:s"), "<br />\n"; ?> Also see the manual page for gmdate() at http://www.php.net/gmdate which shows a very similar script as its first example. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#152942) next »