php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71755 Invalid strtotime() result
Submitted: 2016-03-09 13:48 UTC Modified: 2016-03-09 15:02 UTC
From: yoanrobin at free dot fr Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Windows 7 pro 64bits
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: yoanrobin at free dot fr
New email:
PHP Version: OS:

 

 [2016-03-09 13:48 UTC] yoanrobin at free dot fr
Description:
------------
There is an issue with the strtotime() function.
http://php.net/manual/en/function.strtotime.php

The expression 'first day of this week' neither returns the expected date nor the "false" value.
It will return different dates depending on the PHP version.

Sometimes, it's the "first day of this month", or the first day of the previous month.


Test script:
---------------
echo date('Y-m-d H:i:s', strtotime('random invalid expression'))."\r\n";
echo date('Y-m-d H:i:s', strtotime('first day of this month'))."\r\n";
echo date('Y-m-d H:i:s', strtotime('first day of this week'))."\r\n";

Expected result:
----------------
1970-01-01 01:00:00
2016-03-01 14:38:03
2016-03-07 14:38:03 // or 1970-01-01 01:00:00

Actual result:
--------------
1970-01-01 01:00:00
2016-03-01 14:38:03
2016-03-01 14:38:03

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-09 15:02 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-03-09 15:02 UTC] requinix@php.net
http://php.net/manual/en/datetime.formats.relative.php
"first day of" only works relative to the month.

"first day of this week" behaves something like "first day of (the month of (this week))".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC