Doc #63878 [NEW]: date time function issue problem
| From: | rupesh dot php at gmail dot com | Date: | Mon, 31 Dec 2012 12:55:58 +0000 |
| Subject: | Doc #63878 [NEW]: date time function issue problem | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-9333@lists.php.net to get a copy of this message | ||
From: rupesh dot php at gmail dot com
Operating system:
PHP version: Irrelevant
Package: *General Issues
Bug Type: Documentation Problem
Bug description:date time function issue problem
Description:
------------
---
From manual page:
http://www.php.net/function.date#refsect1-function.date-seealso
---
The date time related functions do not work properly when the current date
is 31st of a month, like today is 31st December 2012.. It seems to be
working on a 30 day principle for a month and does not return the desired
output whenever we you a +/- 1month ting with strtotime() function or with
a mktime() function.
The issue is depicted in the script mentioned below with the output that I
get.
Script ::
---------
for($i=0; $i<6; $i++)
{
echo date("Y-M-d", mktime(0, 0, 0, date("m")-$i, date("d"),
date("Y")))."<br>";
// or even with
// echo date("Y-M-d",
strtotime("-".$i."day"))."<br>";
}
Outputs ::
----------
2012-Dec-31
2012-Dec-01
2012-Oct-31
2012-Oct-01
2012-Aug-31
2012-Jul-31
instead, it should have been ::
-------------
2012-Dec-31
2012-Nov-30
2012-Oct-31
2012-Sep-30
2012-Aug-31
2012-Jul-31
Note that I have only come across this issue with today being 31st of the
month.
Test script:
---------------
for($i=0; $i<6; $i++)
{
echo date("Y-M-d", mktime(0, 0, 0, date("m")-$i, date("d"),
date("Y")))."<br>";
// or even with
// echo date("Y-M-d",
strtotime("-".$i."day"))."<br>";
}
Expected result:
----------------
2012-Dec-31
2012-Nov-30
2012-Oct-31
2012-Sep-30
2012-Aug-31
2012-Jul-31
Actual result:
--------------
2012-Dec-31
2012-Dec-01
2012-Oct-31
2012-Oct-01
2012-Aug-31
2012-Jul-31
--
Edit bug report at https://bugs.php.net/bug.php?id=63878&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63878&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63878&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63878&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63878&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63878&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63878&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63878&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63878&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63878&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63878&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63878&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63878&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63878&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63878&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63878&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63878&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63878&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63878&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63878&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63878&r=mysqlcfg