Bug #55708 [Opn->Bgs]: DateTime->format return wrong Month name "F"
| From: | salathe@php.net | Date: | Fri, 16 Sep 2011 09:58:48 +0000 |
| Subject: | Bug #55708 [Opn->Bgs]: DateTime->format return wrong Month name "F" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163597@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55708&edit=1
ID: 55708
Updated by: salathe@php.net
Reported by: greenrover33 at gmail dot com
Summary: DateTime->format return wrong Month name "F"
-Status: Open
+Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2011-09-16 09:38:51] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55708&edit=1