php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55708 DateTime->format return wrong Month name "F"
Submitted: 2011-09-16 09:38 UTC Modified: 2011-09-16 09:58 UTC
From: greenrover33 at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.8 OS: Ubuntu
Private report: No CVE-ID: None
 [2011-09-16 09:38 UTC] greenrover33 at gmail dot com
Description:
------------
class DateTime return wrong (1 to less) formated date
strftime and date the right one

Output of demo code
~/build/php-5.3.8/sapi/cli# php -f /home/greenrover/www/test.php 
DateTime: September 2006
strftime: Oktober 2006
date:     October 2006

Test script:
---------------
<?php
$unixTimestamp = '1159653600';
$d = date_create('@'.$unixTimestamp);

setlocale(LC_TIME, array('de_CH.UTF-8', 'de_DE@UTF-8', 'de_DE@euro', 'deu'));

echo "DateTime: ".$d->format('F Y');
echo "\n";
echo "strftime: ".strftime("%B %Y", $unixTimestamp);
echo "\n";
echo "date: ".date('F Y', $unixTimestamp);
echo "\n";

Expected result:
----------------
DateTime: Oktober 2006
strftime: Oktober 2006
date:     October 2006

Actual result:
--------------
DateTime: September 2006
strftime: Oktober 2006
date:     October 2006

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-16 09:58 UTC] salathe@php.net
-Status: Open +Status: Bogus
 [2011-09-16 09:58 UTC] salathe@php.net
When creating a DateTime object with "@timestamp", the timezone will be set to 
UTC, as mentioned on http://php.net/manual/en/datetime.construct.php.  
1159653600 in UTC is Sat, 30 Sep 2006 22:00:00 +0000.  

The other functions use the timezone set with date_default_timezone_set(), 
date.timezone, etc. as described in http://php.net/manual/en/function.date-
default-timezone-get.php, which is probably something at least 2 hours east of 
GMT.  For example, 1159653600 in Europe/Berlin is Sun, 01 Oct 2006 00:00:00 
+0200.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 05:01:34 2025 UTC