RE: [PHP] Weird mktime problem
| From: | Naintara Jain | Date: | Thu, 26 Jun 2003 10:46:56 +0000 |
| Subject: | RE: [PHP] Weird mktime problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152948@lists.php.net to get a copy of this message | ||
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: php-general-return-152942-naintara=del6.vsnl.net.in@lists.php.net
[mailto:php-general-return-152942-naintara=del6.vsnl.net.in@lists.php.ne
t]On Behalf Of Ford, Mike [LSS]
Sent: Thursday, June 26, 2003 3:23 PM
To: 'Glenn'; php-general@lists.php.net
Subject: RE: [PHP] Weird mktime problem
> -----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
--
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