Skip to content

strtotime badly handles some localized dates #18615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JamesHeinrich opened this issue May 21, 2025 · 0 comments
Open

strtotime badly handles some localized dates #18615

JamesHeinrich opened this issue May 21, 2025 · 0 comments

Comments

@JamesHeinrich
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants