Skip to content

strtotime badly handles some localized dates #18615

Open
@JamesHeinrich

Description

@JamesHeinrich

Description

The following code:

<?php
echo date('Y-m-d H:i:s', strtotime('Sep-2-2020 01:25:32 PM'))."\n";  // PHP handles this wrong
echo date('Y-m-d H:i:s', strtotime('2-Sep-2020 01:25:32 PM'))."\n";  // PHP handles this right

Resulted in this output:

2025-09-21 15:25:32
2020-09-02 13:25:32

But I expected this output instead:

2020-09-02 13:25:32
2020-09-02 13:25:32

PHP Version

PHP 8.4.7 (cli) (built: May  9 2025 06:54:08) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.7, Copyright (c), by Zend Technologies

Operating System

Ubuntu 22.04.5 LTS (same in Windows 11)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions