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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sascha at mantscheff dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Mon Dec 30 14:01:28 2024 UTC