#22486 [Opn->Bgs]: strtotime +1/-1 Month bug

From: Date: Sat, 01 Mar 2003 05:38:30 +0000
Subject: #22486 [Opn->Bgs]: strtotime +1/-1 Month bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-34567@lists.php.net to get a copy of this message
 ID:               22486
 Updated by:       rasmus@php.net
 Reported By:      drwav at hotpop dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Win32
 PHP Version:      4.2.3
 New Comment:

But would choosing Feb.28 really be any more correct?  If I told you on
January 30 that I would come back in exactly one month to beat the crap
out of you, when would you think I would show up?


Previous Comments:
------------------------------------------------------------------------

[2003-02-28 23:34:53] drwav at hotpop dot com

when strtotime is asked to create a timestaml +1 month in the future,
and is given a timestamp that happens on a day that does not exist in
the next month. A timestamp a few days beyond one month in the future
is created.

Example:

<?php
$now = strtotime("2003-01-30");
$nextmonth = strtotime("+1 month", $now);

print date("Y-m-d", $nextmonth);
?>

the output from this script is

2003-03-02

since February has no 30th day, apparently strtotime just adds 30 days
to whatever timestamp it is given to go one month in the future, hence
March 2nd.

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22486&edit=1



Thread (7 messages)

« previous php.bugs (#34567) next »