[php-src] Issue #10423: DateTimeImmutable fails to parse time when using zero (0) for hour and AM(ante meridiem)

From: Date: Mon, 23 Jan 2023 15:06:07 +0000
Subject: [php-src] Issue #10423: DateTimeImmutable fails to parse time when using zero (0) for hour and AM(ante meridiem)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243546@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10423
Author: Juanchimienti

### Description

The following code:

```php
<?php
$date = new DateTimeImmutable("2023-01-08 00:09:24 AM");

print(print_r($date,TRUE));
```

Resulted in this output:
```
Fatal error: Uncaught Exception: Failed to parse time string (2023-01-08 00:09:24 AM) at position 20
(A): The timezone could not be found in the database in /tmp/poc.php:3
Stack trace:
#0 /tmp/poc.php(3): DateTimeImmutable->__construct('2023-01-08 00:0...')
#1 {main}
  thrown in /tmp/poc.php on line 3

```

But I expected this output instead:
```

DateTimeImmutable Object
(
    [date] => 2023-01-08 00:09:24.000000
    [timezone_type] => 3
    [timezone] => UTC
)

```
While in most places midnight is expressed as "12:00 AM" for a 12-hour clock according to
wikipedia "00:00 AM"  is used in japan: https://en.wikipedia.org/wiki/12-hour_clock



### PHP Version

8.2.1

### Operating System

Debian 11.6


Thread (1 message)

  • Juanchimienti
« previous php.bugs (#243546) next »