-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Description
Description
The following code:
<?php
$dateTimeObj_monday = new DateTimeImmutable('2022W1', new DateTimeZone('Europe/Paris'));Resulted in this output:
PHP Fatal error: Uncaught DateMalformedStringException: Failed to parse time string (2022W1) at position 5 (1): Unexpected character in test.php:7
Stack trace:
#0 /root/test.php(7): DateTimeImmutable->__construct()
But I expected this output instead: a correctly set DateTimeImmutable object.
It seems that the parser refuses to recognize the "W" for week specification.
PHP Version
PHP 8.4.14 (cli) (built: Oct 21 2025 19:23:55) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Fedora Project
Zend Engine v4.4.14, Copyright (c) Zend Technologies
Operating System
Fedora 42