php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44176 Problems with strtotime or strftime and DST
Submitted: 2008-02-19 20:06 UTC Modified: 2008-02-25 22:42 UTC
From: jason dot young at daystar dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.5 OS: win 2003 IIs 6
Private report: No CVE-ID: None
 [2008-02-19 20:06 UTC] jason dot young at daystar dot com
Description:
------------
Ok I'm trying to do some calendar work right during this summers time change hour. 3/9/2008 at 2 a.m. I work for a television network and we have to created scheduals for every hour of every day. (This includes 2 am) strtotime or possibly strftime is not handling that 2:00 am hour correctly here is some testing:

Reproduce code:
---------------
<?php
echo(strftime("%a %m/%d/%y %I:%M %p",(strtotime("3/9/2008 2:00:00 AM")))); 
echo " --- "; 
echo(strftime("%m/%d/%y %I:%M %p",(strtotime("Mar 9 2008 2:00AM")))); 
echo " --- "; 
echo(strtotime("-2 days ",strtotime("03/09/08")));
echo " --- "; 
echo(strtotime("-2 days ", 1205042400));
echo " --- "; 
echo(strtotime("3/9/2008 2:00:00 AM"));
echo " --- "; 
echo(strtotime("Mar 9 2008 2:00AM")); 
?>

Output:
Sun 03/09/08 03:00 AM --- 03/09/08 03:00 AM --- 1204869600 --- 1204869600 --- 1205049600 --- 1205049600

I've tried setting the TZ to US/CDT that didn't help ($test = putenv("TZ=US/CDT");)


Expected result:
----------------
I expect the code to return a formated verson of the date "Mar 9 2008 2:00AM"

Actual result:
--------------
Sun 03/09/08 03:00 AM 

I apologize in advance if this is my misuse. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-25 22:42 UTC] derick@php.net
There is no "2am" in "America/Chicago" on March 9th, as the time goes from 01:59:59 directly to 03:00:00:

zdump -v America/Chicago shows:

America/Chicago  Sun Nov  4 07:00:00 2007 UTC = Sun Nov  4 01:00:00 2007 CST isdst=0 gmtoff=-21600
America/Chicago  Sun Mar  9 07:59:59 2008 UTC = Sun Mar  9 01:59:59 2008 CST isdst=0 gmtoff=-21600
America/Chicago  Sun Mar  9 08:00:00 2008 UTC = Sun Mar  9 03:00:00 2008 CDT isdst=1 gmtoff=-18000
America/Chicago  Sun Nov  2 06:59:59 2008 UTC = Sun Nov  2 01:59:59 2008 CDT isdst=1 gmtoff=-18000
America/Chicago  Sun Nov  2 07:00:00 2008 UTC = Sun Nov  2 01:00:00 2008 CST isdst=0 gmtoff=-21600
America/Chicago  Sun Mar  8 07:59:59 2009 UTC = Sun Mar  8 01:59:59 2009 CST isdst=0 gmtoff=-21600

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 03:02:51 2024 UTC