[PHP-NOTES] note 130627 added to datetimeimmutable.setisodate

[email protected] ("[email protected]") Mon, 26 Jan 2026 15:21:17 +0000
Newsgroups php.notes
Message-ID <[email protected]>
note that giving a week out of range will produce a date for a different year

example:
<?php
$date = new DateTimeImmutable();

$newDate = $date->setISODate(2026, 53);
echo $newDate->format('Y-m-d') . "\n";
// will print "2026-12-28"  (2026 has 53 weeks)

$newDate = $date->setISODate(2026, 54);
echo $newDate->format('Y-m-d') . "\n";
// will print 2027-01-04 which is the 1st week of 2027
?>
----
Server IP: 206.189.2.9
Probable Submitter: 2a01:e11:6008:1850:c28a:94ae:c320:6d30
----
Manual Page -- https://php.net/manual/en/datetimeimmutable.setisodate.php
Edit        -- https://main.php.net/note/edit/130627
Del: integrated  -- https://main.php.net/note/delete/130627/integrated
Del: useless     -- https://main.php.net/note/delete/130627/useless
Del: bad code    -- https://main.php.net/note/delete/130627/bad+code
Del: spam        -- https://main.php.net/note/delete/130627/spam
Del: non-english -- https://main.php.net/note/delete/130627/non-english
Del: in docs     -- https://main.php.net/note/delete/130627/in+docs
Del: other reasons-- https://main.php.net/note/delete/130627
Reject      -- https://main.php.net/note/reject/130627
Search      -- https://main.php.net/manage/user-notes.php