advanced patterns with PHP 8.1 DateTimeImmutable when using custom date formats
I'm working with an scenario with PHP 8.1's `DateTimeImmutable` class when trying to create a date object from a custom string format. My code looks like this: ```php $dateString = '2023-03-25 15:30:00'; $format = 'Y-m-d H:i:s'; $date = DateTimeImmutable::createFromFormat($format, $dateString); ``` However, when I run this, I get the following warning: ``` Warning: DateTimeImmutable::createFromFormat(): Failed to parse time string (2023-03-25 15:30:00) at position 0 (2): Unexpected character ``` I verified that the `$dateString` matches the format specified, so I expected it to work correctly. I even tried using `DateTime::createFromFormat`, and it gives the same warning. I've also checked the PHP documentation, and it mentions that `createFromFormat` should be able to handle this format. To troubleshoot, I’ve tried switching to different date/time formats like `d/m/Y H:i` and `m-d-Y H:i:s`, but I still receive similar warnings. Additionally, I checked the PHP configuration for date settings, but everything seems to be in order. What am I missing here? Is there a specific configuration I need to check or a different method I should use for custom date formats in PHP 8.1?