php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75780 strtotime() outputs wrong xth weekday
Submitted: 2018-01-08 21:16 UTC Modified: 2018-01-08 21:54 UTC
From: anubas at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.2.1 OS: FreeBSD 11.1
Private report: No CVE-ID: None
 [2018-01-08 21:16 UTC] anubas at hotmail dot com
Description:
------------
strtotime() outputs the xth + 1 weekday instead of the xth weekday when the defined month starts on the defined weekday.

Example: The expected output of strtotime('January 2018 third Monday') is the timestamp for '2018-01-15', which is the third Monday of January 2018. Instead, strtotime() outputs the timestamp for '2018-01-22', which is the fourth Monday of January 2018 because that month starts on a Monday.

Test script:
---------------
print 'Expected: 2018-01-15. Result: ' . date('Y-m-d', strtotime('january 2018 third monday'));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-08 21:54 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *Calendar problems +Package: Date/time related
 [2018-01-08 21:54 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

http://php.net/manual/en/datetime.formats.relative.php
"third monday" is a relative term. You want "third monday of".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC