[wp-trac] [WordPress Trac] #25331: date_i18n returns erroneous result
WordPress Trac
noreply at wordpress.org
Mon Sep 16 14:25:54 UTC 2013
#25331: date_i18n returns erroneous result
---------------------------+-----------------------------
Reporter: DavidAnderson | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.6.1
Severity: normal | Keywords:
---------------------------+-----------------------------
My WP timezone is set to London. The time (when I ran my test) was 14:57
local time (13:57 UTC).
Here's the time I'm using to test:
$unixtime = 1379339852;
Results of "/usr/bin/date --date=@1379339852" on my local machine are:
"Mon Sep 16 14:57:32 BST 2013".
I used to use this method to get local times, before I knew of
date_i18n():
{{{
echo get_date_from_gmt( gmdate('Y-m-d H:i:s', $unixtime), 'Y-m-d G:i');
}}}
Result (correct): 2013-09-16 14:57
When I switch to date_i18n (in the same WP install, running this code one
line later than the above):
{{{
echo date_i18n('Y-m-d G:i', $unixtime);
}}}
Result (wrong): 2013-09-16 13:57
Here's a complete terminal session so that you get the full picture:
{{{
$ cat d.php
<?php
require('wp-load.php');
$unixtime = 1379339852;
echo get_date_from_gmt( gmdate('Y-m-d H:i:s', $unixtime), 'Y-m-d
G:i')."\n";
echo date_i18n('Y-m-d G:i', $unixtime)."\n";
$ php d.php
2013-09-16 14:57
2013-09-16 13:57
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25331>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list