php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75606 strtotime("first day this month") vs strtotime("first day of this month")
Submitted: 2017-11-30 21:31 UTC Modified: 2017-12-01 07:29 UTC
From: rafal dot janiczek at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.1.12 OS: Linux
Private report: No CVE-ID: None
 [2017-11-30 21:31 UTC] rafal dot janiczek at gmail dot com
Description:
------------
strtotime("first day this month") gives a date for next month. 

Test script:
---------------
<?php

$d = "first day this month";
echo "'$d': ".date("Y-m-d", strtotime($d)).PHP_EOL;

$d = "first day of this month";
echo "'$d': ".date("Y-m-d", strtotime($d)).PHP_EOL;

echo "Today: ".date("Y-m-d").PHP_EOL;


Expected result:
----------------
'first day this month': 2017-11-01
'first day of this month': 2017-11-01
Today: 2017-11-30


Actual result:
--------------
'first day this month': 2017-12-01
'first day of this month': 2017-11-01
Today: 2017-11-30


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-01 07:29 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-12-01 07:29 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That's right, "last day" and "last day of" do different things.
http://php.net/manual/en/datetime.formats.relative.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC