Bug #71755 [Opn->Nab]: Invalid strtotime() result

From: Date: Wed, 09 Mar 2016 15:02:50 +0000
Subject: Bug #71755 [Opn->Nab]: Invalid strtotime() result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199702@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71755&edit=1

 ID:                 71755
 Updated by:         requinix@php.net
 Reported by:        yoanrobin at free dot fr
 Summary:            Invalid strtotime() result
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Date/time related
 Operating System:   Windows 7 pro 64bits
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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))".


Previous Comments:
------------------------------------------------------------------------
[2016-03-09 13:48:03] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71755&edit=1


Thread (2 messages)

« previous php.bugs (#199702) next »