RE: [PHP] Weird mktime problem
-Original Message- From: Glenn [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Weird mktime problem
You might want to consider removing the leading zeroes, this post is there in the php manual and has been useful to me. -xxx- jchen3625 AT yahoo DOT com (25-Aug-2002 03:33) beware, arguments with leading zeros are treated as zeros. that is, mktime(0,0,0,10,09,2002) == 09/30/2002, whereas mktime(0,0,0,10,9,2002) == 10/09/2002. -xxx- Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of Ford, Mike [LSS] Sent: Thursday, June 26, 2003 3:23 PM To: 'Glenn'; [EMAIL PROTECTED] Subject: RE: [PHP] Weird mktime problem -Original Message- From: Glenn [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Weird mktime problem
Ooops! Make that: ?php $timestamp = 1056405600; echo GMT = , gmdate(Y-m-d H:i:s, $timestamp), br /\n; echo local = , date(Y-m-d H:i:s, $timestamp), br /\n; ? -Original Message- From: Ford, Mike [LSS] Sent: 26 June 2003 10:53 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; ? 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: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Weird mktime problem
On Thursday 26 June 2003 18:46, Naintara Jain wrote: You might want to consider removing the leading zeroes, this post is there in the php manual and has been useful to me. -xxx- jchen3625 AT yahoo DOT com (25-Aug-2002 03:33) beware, arguments with leading zeros are treated as zeros. that is, mktime(0,0,0,10,09,2002) == 09/30/2002, whereas mktime(0,0,0,10,9,2002) == 10/09/2002. -xxx- To be precise, integers written with a leading zero are treated as octal numbers. But octal numbers can only contain digits 0-7. If it contains any other digits then (probably) the whole value is rendered as 0. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* So this it it. We're going to die. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php