Bug #64155 [Com]: Weird bug with time handling
| From: | cmbecker69 at gmx dot de | Date: | Thu, 22 Jan 2015 00:33:55 +0000 |
| Subject: | Bug #64155 [Com]: Weird bug with time handling | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190125@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64155&edit=1
ID: 64155
Comment by: cmbecker69 at gmx dot de
Reported by: espertalhao04 at hotmail dot com
Summary: Weird bug with time handling
Status: Open
Type: Bug
Package: Date/time related
Operating System: any linux distro
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I have rewritten your test script to be able to better explain the
behavior: <http://3v4l.org/I96tr>.
Independently of the default time zone, $time1 has the same value,
but $string1 differs for different default time zones, because
there is no time zone specified for the conversion (other than the
default time zone):
$string1 = date('d-m-Y h:i:s', $time1);
The following results are logical consequences. So there is
clearly no weird bug in time handling, and certainly, specified
time zones are taken into account.
Previous Comments:
------------------------------------------------------------------------
[2013-02-05 12:39:48] espertalhao04 at hotmail dot com
Description:
------------
There is a weird bug in time handling (strtotime and date) functions.
You must specify your timezone to perform operations with specified timezone!
There was no section to write this, so i put it here:
If there is a timezone specified, it should use it to treat this specific date.
Possible solution:
Verify if the timezone is valid, perform offset calculations and return the date.
This way, we would be sure that the date is in the same timezone as specified.
Test script:
---------------
<?=date('d-m-Y h:i:s',strtotime(date('d-m-Y h:i:s',strtotime('02:07:03
Feb 04, 2013 PST'))." GMT"))."<br>"?>
<?date_default_timezone_set('GMT')?>
<?=date('d-m-Y h:i:s',strtotime(date('d-m-Y h:i:s',strtotime('02:07:03
Feb 04, 2013 PST'))." GMT"));?>
<?=date_default_timezone_get()?>
Expected result:
----------------
04-02-2013 10:07:03
04-02-2013 10:07:03 GMT
Actual result:
--------------
04-02-2013 12:07:03
04-02-2013 10:07:03 GMT
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64155&edit=1