php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46589 am/pm issue
Submitted: 2008-11-17 05:28 UTC Modified: 2008-11-25 01:00 UTC
Votes:11
Avg. Score:3.6 ± 1.5
Reproduced:8 of 8 (100.0%)
Same Version:3 (37.5%)
Same OS:2 (25.0%)
From: micah_blu at bluprintsmedia dot net Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: micah_blu at bluprintsmedia dot net
New email:
PHP Version: OS:

 

 [2008-11-17 05:28 UTC] micah_blu at bluprintsmedia dot net
Description:
------------
date() function returns wrong am/pm, usually always outputs am instead of pm

Reproduce code:
---------------
echo date("Y-m-d h:i a");



Expected result:
----------------
//outputs:
2008-11-16 9:26 pm

Actual result:
--------------
//outputs:
2008-11-16 9:26 am

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-17 09:40 UTC] jani@php.net
Well, if you run in before noon you'll get am. Check your server time using 24h format instead of the braindead american am/pm crap.
 [2008-11-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-03-27 00:11 UTC] mjharmon at email dot arizona dot edu
mjharmon@mx ~ $ php timetest.php
2009-03-26 05:03:20 MST GMT-0700 US/Arizona

versus:

mjharmon@mx ~ $ date
Thu Mar 26 17:10:34 MST 2009

mjharmon@mx ~ $ cat timetest.php
<?php
print date('Y-m-d h:m:s T \G\M\TO e') . "\n";

?>


Timezone is correct, date is not.
 [2009-03-27 00:13 UTC] mjharmon at email dot arizona dot edu
Correction, date and timezone are correct. Timestamp (as in the time part) is not correct.
 [2009-03-27 00:30 UTC] mjharmon at email dot arizona dot edu
Update. New results:

mjharmon@mx ~ $ date
Thu Mar 26 17:25:16 MST 2009
mjharmon@mx ~ $ php timetest.php
2009-03-26 05:03:19 MST GMT-0700 US/Arizona
Thu, 26 Mar 2009 17:25:19 -0700

<?php
print date('Y-m-d h:m:s T \G\M\TO e') . "\n";
print date('r');

?>

Apparently, the initial time was GMT (without taking into account the timezone?) But using the rfc2822 format made the date times match up.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 11:01:36 2025 UTC