php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53158 strtotime('next monday') resets the time to 00:00
Submitted: 2010-10-25 22:15 UTC Modified: 2011-12-06 06:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: seld@php.net Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.3.3 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: seld@php.net
New email:
PHP Version: OS:

 

 [2010-10-25 22:15 UTC] seld@php.net
Description:
------------
strtotime() should not reset the time unless specified, "next monday" does reset the time to 00:00, while "next week" does not.

Test script:
---------------
var_dump(strtotime('next monday'));
var_dump(strtotime('next week'));
var_dump(date('Y-m-d H:i:s', strtotime('next monday')));
var_dump(date('Y-m-d H:i:s', strtotime('next week')));

Expected result:
----------------
int 1288641482
int 1288641482
string '2010-11-01 19:58:02' (length=19)
string '2010-11-01 19:58:02' (length=19)

Actual result:
--------------
int 1288569600
int 1288641482
string '2010-11-01 00:00:00' (length=19)
string '2010-11-01 19:58:02' (length=19)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-25 22:16 UTC] seld@php.net
-Assigned To: +Assigned To: derick
 [2011-03-01 18:57 UTC] tomas dot brastavicius at quantum dot lt
These also reset time:

echo date('Y-m-d H:i:s', strtotime('+1 monday')) . "\n";
echo date('Y-m-d H:i:s', strtotime('first monday')) . "\n";
echo date('Y-m-d H:i:s', strtotime('first monday of March 2011'));
 [2011-03-01 19:26 UTC] derick@php.net
There is a reason for this... can't remember it now. I don't think it's a "bug"... but will investigate at some point.
 [2011-12-06 06:15 UTC] derick@php.net
-Status: Assigned +Status: Bogus
 [2011-12-06 06:15 UTC] derick@php.net
Duplicate of #54909
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC