php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16594 mktime() when passed a 0 for the day of the month to get the last day is broken
Submitted: 2002-04-14 02:34 UTC Modified: 2002-04-14 08:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: lchang at cc dot gatech dot edu Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.1.2 OS: FreeBSD 4.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lchang at cc dot gatech dot edu
New email:
PHP Version: OS:

 

 [2002-04-14 02:34 UTC] lchang at cc dot gatech dot edu
When you use mktime(0,0,0,<month>,<day>,<year>) and specify 0 as the day to get the last day of the month, the last day of the month returned is off. It seems that the months are all off by 1 after January. So with mktime(), for February, the last day is the 31st, for March it is the 28th, for April it is the 31st, etc. And instead February should be the 28th, March the 31st, and April the 30th, etc...

<?php
  //Last day should be 28, but is 31
  $day = getdate( mktime(0,0,0,2,0,2002) );
  print 'The last day for February is: ' . $day[mday]
        .'<br>';
  //Last day should be 31, but is 28
  $day = getdate( mktime(0,0,0,3,0,2002) );
  print 'The last day for March is: ' . $day[mday];
  
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-14 08:34 UTC] hholzgra@php.net
intended behaviour

day zero is the day before the first day of
the given month, so it is obviously the last
day of the month *before* the given one
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 19:01:31 2024 UTC