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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 08:01:35 2024 UTC