note 105603 added to function.strtotime
| From: | hushuilong at gmail dot com | Date: | Wed, 31 Aug 2011 09:37:51 +0000 |
| Subject: | note 105603 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182851@lists.php.net to get a copy of this message | ||
There is a bug when around a month change.
The bug url: https://bugs.php.net/bug.php?id=27793
To work around this ,check the method below :
Pass the timestamp of the first second on the first day in current month to strtotime the second
parameter.
<?php
date_default_timezone_set('Asia/Shanghai');
$first_day_of_month = date('Y-m',time()) . '-01 00:00:01';
$t = strtotime($first_day_of_month);
print_r(array(
date('Y-m',$t),
date('Y-m',strtotime('- 1 month',$t)),
date('Y-m',strtotime('- 2 month',$t)),
));
?>
----
Server IP: 222.73.207.145
Probable Submitter: 127.0.0.1 (proxied: 119.145.40.161)
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/105603
Del: integrated -- https://master.php.net/note/delete/105603/integrated
Del: useless -- https://master.php.net/note/delete/105603/useless
Del: bad code -- https://master.php.net/note/delete/105603/bad+code
Del: spam -- https://master.php.net/note/delete/105603/spam
Del: non-english -- https://master.php.net/note/delete/105603/non-english
Del: in docs -- https://master.php.net/note/delete/105603/in+docs
Del: other reasons-- https://master.php.net/note/delete/105603
Reject -- https://master.php.net/note/reject/105603
Search -- https://master.php.net/manage/user-notes.php