|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 17:00:02 2025 UTC | 
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.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.