php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48232 date_modify miscalculates forward from end of month
Submitted: 2009-05-11 07:28 UTC Modified: 2009-05-11 08:51 UTC
From: vqkq7ov02 at sneakemail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vqkq7ov02 at sneakemail dot com
New email:
PHP Version: OS:

 

 [2009-05-11 07:28 UTC] vqkq7ov02 at sneakemail dot com
Description:
------------
When date_modify() is given the last day of a month and asked to add one weekday (e.g. +1 Sunday), if the last day of the month is that same weekday, then date_modify() doesn't add a week-- it returns the same date it was given.

This problem occurs in PHP 5.2.9.  It doesn't occur in PHP 5.2.6, which returns the correct result.


Reproduce code:
---------------
<?php
echo "PHP Version = ", phpversion(), "\n";
$dt = new DateTime();
date_date_set($dt, 2009, 5, 31);
echo 'Before date_modify: ', $dt->format('l m/j/y'), "\n";
$action = "+1 Sunday";
date_modify($dt, $action);
echo "After date_modify ($action): ",  $dt->format('l m/j/y') , "\n",
    "Should be Sunday 6/7/09\n";
?>


Expected result:
----------------
PHP Version = 5.2.6-3ubuntu4.1
Before date_modify: Sunday 05/31/09
After date_modify (+1 Sunday): Sunday 06/7/09
Should be Sunday 6/7/09


Actual result:
--------------
PHP Version = 5.2.9-2
Before date_modify: Sunday 05/31/09
After date_modify (+1 Sunday): Sunday 05/31/09
Should be Sunday 6/7/09

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-11 08:51 UTC] jani@php.net
See bug #46932 (strtotime() is same thing :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC