php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7518 Rounding problems with mktime() or date()
Submitted: 2000-10-29 05:56 UTC Modified: 2000-10-29 09:03 UTC
From: sascha at mantscheff dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.0.1pl2 OS: SuSE Linux 6.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
21 - 17 = ?
Subscribe to this entry?

 
 [2000-10-29 05:56 UTC] sascha at mantscheff dot net
<?php
        $DAYS = 3600 * 24;
        $fdom = mktime( 0, 0, 0, 10, 8, 2000 );
        for ($i = 1; $i < 30; $i++)
                echo date( "d.m.Y", $fdom + ($i - 1) * $DAYS ) . " ";
?>

This script should list the day number from October, 08th, through the next 30 days. It repeats the 29th day of October. I don't know why.

If the 3rd line is changed to
        $fdom = mktime( 0, 0, 0, 10, 08, 2000 );
date counting starts on September 30th, so the leading 0 of "08" is misinterpreted as a standalone zero.


 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-29 09:03 UTC] jah@php.net
There was switch to daylight saving on your timezone, so
the difference between 2000-10-29 00:00:00 and 2000-10-30 00:00:00 is 90000 seconds, not 86400. Always some other
time, for example 12:00:00, which will fall on the right
date even when there is 23 or 25 hours in day and you go
forward in steps of 86400 seconds.

In your second example, numbers beginning with a leading
zero are *octal* numbers, and 08 is a non-existent octal
number.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC