|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-15 11:19 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Feb 06 17:00:02 2026 UTC |
Description: ------------ When converting weeks and days to a date using strtotime, some months return the wrong dates. For instance, strtotime("first thursday", mktime(0,0,0,11,1,2009)) returns 11/4/2009, which is a wednesday. There are also issues using "last". This seems to be happening with November 2009. I am not sure about other years or other months. I think I had issues there as well, but infrequently. I tried seeing if the issue is with any month when the first day of the month is sunday, but it does not appear to be the case. I am creating a new function to handle strtotime in this manner, because I found more issues with using this function and creating a series of dates that are incremented by a year. Reproduce code: --------------- public function getDateFromWeekAndDayOfMonth($d, $m, $y){ $fistDayOfMonth = mktime(0, 0, 0, $m, 1, $y) $firstWeekForDay = strtotime("first " . $d, $fistDayOfMonth); return $firstWeekForDay; } Expected result: ---------------- For the First Thursday in November 1, 2009, I expect to have the datetime for 11-5-2009. Actual result: -------------- 11-4-2009