php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51439 "last month" in date does not right on March 30th
Submitted: 2010-03-30 14:32 UTC Modified: 2010-03-30 15:27 UTC
From: ml at stefanbongartz dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.2 OS: Ubuntu 9.x, Debian 4.x
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: ml at stefanbongartz dot de
New email:
PHP Version: OS:

 

 [2010-03-30 14:32 UTC] ml at stefanbongartz dot de
Description:
------------
On March 30th and 31th the date function does not work correctly. If you work with date("m")-1 the result is not 02 for the month. You get 03 for the month but 02 for the day!!

If you change the system clock to another date the funtion works correctly. See code below. 

If you set the clock to Apr 30th and use date('m')-2 you get the same wrong result.

Test script:
---------------
echo "<br>today: ". $today  = mktime(0, 0, 0, date("m")  , date("d"), date("Y"));
echo "<br>". date('d.m.Y', $today);
echo "<br>";

echo "<br>tomorrow: ". $tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
echo "<br>". date('d.m.Y', $tomorrow);
echo "<br>";

echo "<br>last1month: ". $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"),   date("Y"));
echo "<br>". date('d.m.Y', $lastmonth);
echo "<br>";

echo "<br>last2month: ". $lastmonth = mktime(0, 0, 0, date("m")-2, date("d"),   date("Y"));
echo "<br>". date('d.m.Y', $lastmonth);
echo "<br>";

echo "<br>last3month: ". $lastmonth = mktime(0, 0, 0, date("m")-3, date("d"),   date("Y"));
echo "<br>". date('d.m.Y', $lastmonth);
echo "<br>";


Expected result:
----------------
30.02.2010

Actual result:
--------------
02.03.2010

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-30 15:27 UTC] derick@php.net
-Status: Open +Status: Bogus
 [2010-03-30 15:27 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://derickrethans.nl/obtaining-the-next-month-in-php.html
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC