Bug #53942 [Opn->Bgs]: Unexpected date("m",mktime_output) Output
| From: | dtajchreber@php.net | Date: | Mon, 07 Feb 2011 01:44:33 +0000 |
| Subject: | Bug #53942 [Opn->Bgs]: Unexpected date("m",mktime_output) Output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158534@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53942&edit=1
ID: 53942
Updated by: dtajchreber@php.net
Reported by: jay_roplekar at hotmail dot com
Summary: Unexpected date("m",mktime_output) Output
-Status: Open
+Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
$tm = date('Y-m-d H:i:s');
$quarter = ceil(date("m", $tm)/3);
Your example doesn't make sense. The second parameter of date should be
a Unix
timestamp... date('Y-m-d H:i:s') returned a formatted date string. Use
time(),
mktime(), strtotime(), date("U"), or any number of the other functions
that
return a Unix timestamp to create your $tm variable...
Previous Comments:
------------------------------------------------------------------------
[2011-02-06 22:35:05] jay_roplekar at hotmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.date
---
$tm = date('Y-m-d H:i:s');
$quarter = ceil(date("m", $tm)/3);
echo '<br> Current Quarter Is: '.$quarter.' Because date
is:'.date("m",
$tm).' Time is:'.$tm.' month is:'.date("m").'<br>';
####
Output Below shows that date("m", $tm) is producing wrong output, but
date("m") is producing correct output. The PHP version is
5.2.10-2ubuntu6.5 but I believe that does not matter as the bug reports
I have reviewed don't talk about this behavior.
####
Current Quarter Is: 4 Because date is:12 Time is:2011-02-06 15:25:00
month is:02
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53942&edit=1