php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60980 date with strtotime
Submitted: 2012-02-05 18:29 UTC Modified: 2012-02-05 18:32 UTC
From: moh dot e at live dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.10 OS: debian
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: moh dot e at live dot com
New email:
PHP Version: OS:

 

 [2012-02-05 18:29 UTC] moh dot e at live dot com
Description:
------------
I used this function as below but i have problem in February  month
if 'user_invoice_date' equal 2012-01-30 or 2012-01-31
the 'new_invoice_date' equal 2012-03-01
$new_invoice_date=date("Y-m-01 H:i:s",strtotime($user_invoice_date."+1 month"));

Test script:
---------------
normal 
$user_invoice_date="2011-12-31";
$new_invoice_date=date("Y-m-01 H:i:s",strtotime($user_invoice_date."+1 month"));
////////////////
Error
$user_invoice_date="2012-01-31";
$new_invoice_date=date("Y-m-01 H:i:s",strtotime($user_invoice_date."+1 month"));
echo $new_invoice_date;

Expected result:
----------------
$user_invoice_date="2012-01-31";
$new_invoice_date=date("Y-m-01 H:i:s",strtotime($user_invoice_date."+1 month"));

$new_invoice_date=2012-02-01

2012-02-01

Actual result:
--------------
$new_invoice_date=2012-03-01

2012-03-01

Patches

dat-time-problem (last revision 2012-02-05 18:32 UTC by moh dot e at live dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-05 18:32 UTC] derick@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

There are numerous occasions of this "non bug" in the database. This is not a bug: http://derickrethans.nl/obtaining-the-next-month-in-php.html
 [2012-02-05 18:32 UTC] derick@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 10 21:01:29 2024 UTC