Edit report at https://bugs.php.net/bug.php?id=66257&edit=1
ID: 66257
Updated by: derick@php.net
Reported by: mfaust at usiwireless dot com
Summary: strtotime doesn't use current timezone on '4
thursdays'
-Status: Open
+Status: Feedback
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 5.4.22
Block user comment: N
Private report: N
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
The following works just fine here:
<?php
date_default_timezone_set("America/Chicago");
$timestamp = mktime(0,0,0,11,1,2014);
$a = strtotime('4 thursdays', $timestamp);
$b = strtotime('first thursday + 3 weeks', $timestamp);
echo date(DateTime::ISO8601, $a), "\n";
echo date(DateTime::ISO8601, $b), "\n";
?>
outputs:
2014-11-27T00:00:00-0600
2014-11-27T00:00:00-0600
This is with PHP 5.4.24
Previous Comments:
------------------------------------------------------------------------
[2013-12-10 18:09:07] mfaust at usiwireless dot com
Description:
------------
---
From manual page: http://www.php.net/function.strtotime
---
date_default_timezone_set('UTC');
$timestamp = mktime(0,0,0,11,1,2014);
strtotime('4 thursdays', $timestamp) does not return the same timestamp as
strtotime('first thursday + 3 weeks', $timestamp)
The first call returns a timestamp indicating a time of 6am (we are in CST) and the second returns a
timestamp indicating 12am.
Test script:
---------------
//The server timezone is America/Chicago
$timestamp = mktime(0,0,0,11,1,2014);
echo strtotime('4 thursdays', $timestamp) . "\n";
strtotime('first thursday + 3 weeks', $timestamp) . "\n";
Expected result:
----------------
Both should return the same timestamp indicating 12:00 am.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66257&edit=1