php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51560 strtotime not working in certain cases
Submitted: 2010-04-15 12:29 UTC Modified: 2011-12-04 02:49 UTC
From: attand at gmail dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: Irrelevant OS: linux
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: attand at gmail dot com
New email:
PHP Version: OS:

 

 [2010-04-15 12:29 UTC] attand at gmail dot com
Description:
------------
$maxDate = mktime(0, 0, 0, 12, 1, 2009) ;
print date("Y-m-d", strtotime("-1 months", $maxDate)) ;

returns "2009-12-01" 



Expected result:
----------------
My understanding is that it should return "2009-11-30"

Besides where can i find the list of str parameter to be used in strtotime(str $time,int $now) 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-15 12:50 UTC] derick@php.net
-Status: Open +Status: Feedback
 [2010-04-15 12:50 UTC] derick@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


Not sure what you're doing here, but the script works perfectly fine here:

derick@kossu:/tmp$ cat bug51560.phpt
--FILE--
<?php
echo date_default_timezone_get(), "\n";
echo phpversion(), "\n";

$maxDate = mktime(0, 0, 0, 12, 1, 2009);
var_dump( $maxDate );
echo date( DateTime::RFC2822 . ' e', $maxDate ), "\n";
$newDate = strtotime("-1 months", $maxDate);
var_dump( $newDate );
echo date( DateTime::RFC2822 . ' e', $newDate ), "\n";

echo date( 'Y-m-d', $newDate ), "\n";
?>
derick@kossu:/tmp$ php bug51560.phpt 

--FILE--
Europe/London
5.3.3-dev
int(1259625600)
Tue, 01 Dec 2009 00:00:00 +0000 Europe/London
int(1257033600)
Sun, 01 Nov 2009 00:00:00 +0000 Europe/London
2009-11-01
 [2011-12-04 02:49 UTC] frozenfire@php.net
-Status: Feedback +Status: No Feedback
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 05:01:31 2024 UTC