php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #46930 5.3.0alpha3's strtotime() returns inconsistent result with some relative items
Submitted: 2008-12-22 23:09 UTC Modified: 2009-05-03 14:45 UTC
From: for-bugs at hnw dot jp Assigned: derick (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.0alpha3 OS: any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: for-bugs at hnw dot jp
New email:
PHP Version: OS:

 

 [2008-12-22 23:09 UTC] for-bugs at hnw dot jp
Description:
------------
strtotime() of PHP 5.3.0alpha3 returns inconsistent and incompatible result with 'first day' 'last day' 'previous week' 'next week'.

PHP 5.2.8 produces consistent result, and meaning of 'first' 'next' 'last' 'previous' is clear for me.

The behaviour of PHP 5.3.0's strtotime() is sometimes natural, but it lacks consistency and documentation, I think.

Reproduce code:
---------------
<?php

var_dump(date("Y-m-d", strtotime("20081224 first day")));
var_dump(date("Y-m-d", strtotime("20081224 next day")));

var_dump(date("Y-m-d", strtotime("20081224 last day")));
var_dump(date("Y-m-d", strtotime("20081224 previous day")));

var_dump(date("Y-m-d", strtotime("20081224 first week")));
var_dump(date("Y-m-d", strtotime("20081224 next week")));

var_dump(date("Y-m-d", strtotime("20081224 last week")));
var_dump(date("Y-m-d", strtotime("20081224 previous week")));

Expected result:
----------------
string(10) "2008-12-25"
string(10) "2008-12-25"
string(10) "2008-12-23"
string(10) "2008-12-23"
string(10) "2008-12-31"
string(10) "2008-12-31"
string(10) "2008-12-17"
string(10) "2008-12-17"

Actual result:
--------------
string(10) "2008-12-01"
string(10) "2008-12-25"
string(10) "2008-12-31"
string(10) "2008-12-23"
string(10) "1970-01-01"
string(10) "2008-12-29"
string(10) "2008-12-15"
string(10) "2008-12-15"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-23 14:14 UTC] derick@php.net
5.3 does the proper behavior.
 [2009-05-03 14:45 UTC] derick@php.net
Duplicate of #42489 — also, the PHP 5.3 behaviour is correct. Fixing this in 5.2 would require merging too much code that can break other things, so I don't think it's wise to merge.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 15:01:27 2025 UTC