php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9998 mktime() calculation error - 25 hours in a day
Submitted: 2001-03-26 12:05 UTC Modified: 2001-03-26 12:31 UTC
From: beartales at earthlink dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.0.4pl1 OS: freebsd 4.2
Private report: No CVE-ID: None
 [2001-03-26 12:05 UTC] beartales at earthlink dot net
using mktime() one day per year has 25 hours in it
if you substract one date from the previous day and divide
by 3600 you should find there are 24 hours in that day.
however, one day per year has 25 hours.
so far i have found one day per year.
and a different day every year.

10/29/2000    25 hours
10/28/2001    25 hours
10/27/2002    25 hours

to reproduce the problem:

(mktime(0,0,0,10,30,2000)-mktime(0,0,0,10,29,2000))/3600

(mktime(0,0,0,10,29,2001)-mktime(0,0,0,10,28,2001))/3600

(mktime(0,0,0,10,28,2002)-mktime(0,0,0,10,27,2002))/3600

i found the problem because i was creating date ranges for
the user and putting them into a database. if i add the
number of days in a month to a date, i should then have the
same numeric date in the new month. for instance convert
08/10/2001:
$new_day = mktime(0,0,0,8,10,2001) + ( 31 * 86400 ) 
 ( 31 number of days in august ) 
 ( 86400 seconds in a day ) 
convert back to date  date("Y-m-d", $new_day )
should and does = 09/10/2001 

i have now tried this on two different servers.
one - PII 350 freebsd 4.2, apache 1.3.17, php 4.0.4pl1 
two - PIII 667 freebsd 4.2, apache 1.3.17, php 4.0.4pl1

both return the same problem

thanks for any insight
James Lose  03/26/2001

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-26 12:31 UTC] eschmid@php.net
Thats not an bug. You can find another day in the year which have 23 hours. It's the day light saving.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 22 22:03:37 2022 UTC