php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53942 Unexpected date("m",mktime_output) Output
Submitted: 2011-02-06 22:35 UTC Modified: 2011-02-07 02:44 UTC
From: jay_roplekar at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Ubuntu
Private report: No CVE-ID: None
 [2011-02-06 22:35 UTC] 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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-07 02:44 UTC] dtajchreber@php.net
-Status: Open +Status: Bogus
 [2011-02-07 02:44 UTC] dtajchreber@php.net
$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...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 23:01:30 2024 UTC