php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46459 Daylight Savings doesn't work with the UTC time zone
Submitted: 2008-11-01 21:35 UTC Modified: 2008-11-01 22:54 UTC
From: phpbugs at enduringresults dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.6 OS: Fedora Core 9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
8 - 3 = ?
Subscribe to this entry?

 
 [2008-11-01 21:35 UTC] phpbugs at enduringresults dot com
Description:
------------
Daylight Savings doesn't work with the UTC time zone
It does work if I set the time zone to Europe/London.

Reproduce code:
---------------
<?php
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $tw?php
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n\n";
date_default_timezone_set("Europe/London");
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:o_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n\n";
date_default_timezone_set("Europe/London");
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n\n";
date_default_timezone_set("UTC");
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n";
?>


Expected result:
----------------
UTC
18-Oct-2008 10:17:25 UTC 1
01-Nov-2008 09:17:25 UTC 0

Europe/London
18-Oct-2008 10:17:25 BST 1
01-Nov-2008 09:17:25 GMT 0

UTC
18-Oct-2008 10:17:25 UTC 1
01-Nov-2008 09:17:25 UTC 0


Actual result:
--------------
UTC
18-Oct-2008 09:17:25 UTC 0
01-Nov-2008 09:17:25 UTC 0

Europe/London
18-Oct-2008 10:17:25 BST 1
01-Nov-2008 09:17:25 GMT 0

UTC
18-Oct-2008 09:17:25 UTC 0
01-Nov-2008 09:17:25 UTC 0


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-01 21:48 UTC] phpbugs at enduringresults dot com
The code got scrambled when cutting and pasting. Here's the correct code.
===================
<?php
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n\n";
date_default_timezone_set("Europe/London");
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n\n";
date_default_timezone_set("UTC");
echo date_default_timezone_get() . "\n";
$two_weeks_ago = date("d-M-Y h:i:s T I", time()-1209600);
echo $two_weeks_ago . "\n";
$right_now = date("d-M-Y h:i:s T I", time());
echo $right_now . "\n";
?>
 [2008-11-01 22:54 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

There's no daylight saving time with UTC.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC