php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52261 strtotime() worng result when timezome only.
Submitted: 2010-07-06 05:11 UTC Modified: 2013-09-17 17:13 UTC
From: n-ishii at chiether dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.2 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: n-ishii at chiether dot net
New email:
PHP Version: OS:

 

 [2010-07-06 05:11 UTC] n-ishii at chiether dot net
Description:
------------
Time Formats: tz format (JST, UTC, GMT, EST...) has problem. maybe wrong (+/-)


Test script:
---------------
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Asia/Tokyo"


<?php
$now = time();

$local  = date("Y-m-d H:i:s",$now);
$gmdate = gmdate("Y-m-d H:i:s",$now);

$tz  = date_default_timezone_get();
$jst = date("Y-m-d H:i:s", strtotime("JST",$now));
$gmt = date("Y-m-d H:i:s", strtotime("GMT",$now));
$utc = date("Y-m-d H:i:s", strtotime("UTC",$now));
$est = date("Y-m-d H:i:s", strtotime("EST",$now));
$edt = date("Y-m-d H:i:s", strtotime("EDT",$now));

echo "
[TIMEZONE:{$tz}]
  DATE: {$local}
GMDATE: {$gmdate}
----
GMT: {$gmt}
UTC: {$utc}
JST: {$jst} (UTC +9)
EDT: {$edt} (UTC -4)
EST: {$est} (UTC -5)
";


Expected result:
----------------
[TIMEZONE:Asia/Tokyo]
  DATE: 2010-07-06 11:58:03
GMDATE: 2010-07-06 02:58:03
----
GMT: 2010-07-06 20:58:03
UTC: 2010-07-06 20:58:03
JST: 2010-07-06 11:58:03 (UTC +9)
EDT: 2010-07-07 00:58:03 (UTC -4)
EST: 2010-07-07 01:58:03 (UTC -5)


Actual result:
--------------
[TIMEZONE:Asia/Tokyo]
  DATE: 2010-07-06 11:58:03
GMDATE: 2010-07-06 02:58:03
----
GMT: 2010-07-06 02:58:03
UTC: 2010-07-06 02:58:03
JST: 2010-07-06 11:58:03 (UTC +9)
EDT: 2010-07-05 22:58:03 (UTC -4)
EST: 2010-07-05 21:58:03 (UTC -5)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-06 07:24 UTC] n-ishii at chiether dot net
or is it design?

so example...,
EST: 2010-07-05 21:58:03 (-5h)
UTC: 2010-07-06 02:58:03 ( 0h)
JST: 2010-07-06 11:58:03 (+9h) * local timezone.

strtotime("EST");
-> (localdate+EST) "2010-07-06 11:58:03 EST"
-> (convert UTC)   "2010-07-06 16:58:03 UTC"
-> (timezone:JST)  time-value on "2010-07-06 01:58:03 JST"
 [2010-07-06 07:29 UTC] n-ishii at chiether dot net
sorry mistake posted.
-> (timezone:JST)  time-value on "2010-07-07 01:58:03 JST"
 [2013-09-17 12:49 UTC] cmbecker69 at gmx dot de
The actual results are absolutely fine, e.g.

> UTC: 2010-07-06 02:58:03
> JST: 2010-07-06 11:58:03 (UTC +9)

UTC+9 means, add 9 hours to the time expressed as UTC and you 
get the local time (JST).

IMHO this is not a bug.
 [2013-09-17 17:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2013-09-17 17:13 UTC] requinix@php.net
The only thing I see wrong is the dates in the Expected Result. Like, GMDATE and 
GMT should be the same time...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 02 08:01:28 2025 UTC