|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-03-06 22:27 UTC] daniel at honestempire dot com
Description:
------------
When attempting to find the last weekday of February 2016, I stumbled across this bug. See the test script for replication information.
Test script:
---------------
$lastDayOfMonth = date('tS F Y', strtotime('2016-02-01 12:00:00'));
var_dump($lastDayOfMonth); // string(18) "29st February 2016"
var_dump(date('d', strtotime(sprintf('last weekday %s', $lastDayOfMonth)))); // string(2) "26" (should be string(2) "29")
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 23:00:01 2025 UTC |
'S' works according to the date you passed, which was Feb 1. 't' is merely the number of days in the month and will not magically turn the date into Feb 29. // 03-00 will underflow to whichever is the last day of February $lastDayOfMonth = date('jS F Y', strtotime('2016-03-00 12:00:00'));