Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

#22163 [Fbk->Opn]: mktime returns -3662

0 views
Skip to first unread message

and...@strawberry-world.com

unread,
Feb 11, 2003, 3:55:11 PM2/11/03
to
ID: 22163
User updated by: and...@strawberry-world.com
Reported By: and...@strawberry-world.com
-Status: Feedback
+Status: Open
Bug Type: Date/time related
Operating System: MacOS X 10.2
PHP Version: 4.3.0
New Comment:

Sorry if I misunderstand, but as my first post shows I have tried the
year as 2003, as well as 03. No difference, and using the 29th as the
day instead works.


Previous Comments:
------------------------------------------------------------------------

[2003-02-11 10:22:27] il...@php.net

I think that for some reason on your system, 03 is interpreted as 0003
and not 2003 as you intended (works fine on linux). Could you try
changing the year to 2003 and see if that fixes the problem?

------------------------------------------------------------------------

[2003-02-11 04:51:50] and...@strawberry-world.com

Hello

the function mktime seems to return an incorrect value for
certain dates.

Example:

$the_day=mktime(0,0,0,03,30,03);

returns the value -3662

I have also tried different variations:
$the_day=mktime(0,0,0,3,30,03);
$the_day=mktime(0,0,0,03,30,2003);

But all yield the same result.

If I use:
$the_day=mktime(0,0,0,03,29,03);

I get a UNIX timestamp back as expected.

When using the mktime() function I normally also specify
the daylight savings time value of 0, but this also makes
no difference, whether it is 0 or 1.

I am using PHP as built by www.entropy.ch


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=22163&edit=1

and...@strawberry-world.com

unread,
Feb 12, 2003, 3:31:35 AM2/12/03
to
ID: 22163
User updated by: and...@strawberry-world.com
Reported By: and...@strawberry-world.com
-Status: Feedback
+Status: Open
Bug Type: Date/time related
Operating System: MacOS X 10.2
PHP Version: 4.3.0
New Comment:

Yes, I have also tried (and just tried it again to make sure):

$the_day=mktime(0,0,0,3,30,2003);

Same result, -3662

Anything else I can try to narrow down where the problem might be
lying?


Previous Comments:
------------------------------------------------------------------------

[2003-02-11 15:29:51] sni...@php.net

Did you try:

$the_day=mktime(0,0,0,3,30,2003);

??


------------------------------------------------------------------------

[2003-02-11 14:55:01] and...@strawberry-world.com

Sorry if I misunderstand, but as my first post shows I have tried the
year as 2003, as well as 03. No difference, and using the 29th as the
day instead works.

------------------------------------------------------------------------

and...@strawberry-world.com

unread,
Feb 12, 2003, 6:53:11 AM2/12/03
to
ID: 22163
User updated by: and...@strawberry-world.com
Reported By: and...@strawberry-world.com
-Status: Feedback
+Status: Open
Bug Type: Date/time related
Operating System: MacOS X 10.2
PHP Version: 4.3.0
New Comment:

ok, I used the script:
<?PHP

$the_day=mktime(0,0,0,3,30,2003);
echo "$the_day<br>";
echo "23:59:59 29-Mar = ", mktime(23, 59, 59, 3, 29, 2003), ";
01:00:01 30-Mar = ", mktime(1, 0, 1, 3, 30, 2003);

?>

and got:

-3662
23:59:59 29-Mar = 1048982399; 01:00:01 30-Mar = -61

I thought it might be a daylight savings time problem as well, hence I
thought the extra parameter I normally use would solve the problem, but
it didn't. i.e.
$the_day=mktime(0,0,0,3,30,2003,0);


Previous Comments:
------------------------------------------------------------------------

[2003-02-12 05:31:04] m...@php.net

Of course, I meant "; 01:00:01 30-Mar = " in the second line (although
the mktime() call is correct)!

------------------------------------------------------------------------

[2003-02-12 05:27:07] m...@php.net

I think this must be related to daylight savings time -- 30th March
2003 is certainly the date on which DST begins in western Europe.

Can you try this, and see what you get:

echo "23:59:59 29-Mar = ", mktime(23, 59, 59, 3, 29, 2003),
"; 00:00:01 30-Mar = ", mktime(1, 0, 1, 3, 30, 2003);

If those timestamps are 2 seconds apart, then your original mktime() is
falling into the limbo of the "lost hour" due to the clocks going back
(the second after 29-Mar-2003 23:59:59 must be regarded as 30-Mar-2003
01:00:00), and the algorithm used on your system returns a nonsense
value when that happens.

Mike

------------------------------------------------------------------------

[2003-02-12 02:31:17] and...@strawberry-world.com

Yes, I have also tried (and just tried it again to make sure):

$the_day=mktime(0,0,0,3,30,2003);

Same result, -3662

Anything else I can try to narrow down where the problem might be
lying?

------------------------------------------------------------------------

[2003-02-11 15:29:51] sni...@php.net

Did you try:

$the_day=mktime(0,0,0,3,30,2003);

??


------------------------------------------------------------------------

[2003-02-11 14:55:01] and...@strawberry-world.com

Sorry if I misunderstand, but as my first post shows I have tried the
year as 2003, as well as 03. No difference, and using the 29th as the
day instead works.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/22163

and...@strawberry-world.com

unread,
Feb 12, 2003, 8:43:07 AM2/12/03
to
ID: 22163
User updated by: and...@strawberry-world.com
Reported By: and...@strawberry-world.com
-Status: Feedback
+Status: Open
Bug Type: Date/time related
Operating System: MacOS X 10.2
PHP Version: 4.3.0
New Comment:

really screwy then :-)

With the script:
<?PHP

$the_day=mktime(0,0,0,3,30,2003);
echo "$the_day<br>";
echo "23:59:59 29-Mar = ", mktime(23, 59, 59, 3, 29, 2003), ";

01:01:03 30-Mar = ", mktime(1, 1, 3, 3, 30, 2003);

?>

I get the result:
-3662
23:59:59 29-Mar = 1048982399; 01:01:03 30-Mar = -1


Previous Comments:
------------------------------------------------------------------------

[2003-02-12 07:28:21] m...@php.net

H'mmm -- I get

23:59:59 29-Mar = 1048982399; 01:00:01 30-Mar = 1048982401

on my system, which is what I expected from your report. There seems
to be an extra minute or so of limbo on yours for some reason. Can you
try again with:

mktime(1, 1, 3, 3, 30, 2003)

and let us know the result. If it's about 1048982463, then it seems
there's a whole minute in there for which you don't seem to be able to
get a valid time. If it's anything else, then something is really
screwy. Either way, it seems to be a real bug.


------------------------------------------------------------------------

[2003-02-12 05:53:05] and...@strawberry-world.com

ok, I used the script:
<?PHP

$the_day=mktime(0,0,0,3,30,2003);
echo "$the_day<br>";
echo "23:59:59 29-Mar = ", mktime(23, 59, 59, 3, 29, 2003), ";
01:00:01 30-Mar = ", mktime(1, 0, 1, 3, 30, 2003);

?>

and got:

-3662
23:59:59 29-Mar = 1048982399; 01:00:01 30-Mar = -61

I thought it might be a daylight savings time problem as well, hence I
thought the extra parameter I normally use would solve the problem, but
it didn't. i.e.
$the_day=mktime(0,0,0,3,30,2003,0);

------------------------------------------------------------------------

------------------------------------------------------------------------

Mike

------------------------------------------------------------------------

$the_day=mktime(0,0,0,3,30,2003);

Same result, -3662

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view

0 new messages