[php-src] Issue #21027: strtotime() has strange interpretation of decimal weeks
| From: | hartman | Date: | Sat, 24 Jan 2026 17:20:01 +0000 |
| Subject: | [php-src] Issue #21027: strtotime() has strange interpretation of decimal weeks | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251595@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/21027
Author: hartman
### Description
The following code:
```php
<?php
strtotime("2.37685 weeks");
```
Resulted in this output:
```
1613443020
```
The code interpreted 2.37685 weeks as 02:37 (hours) and 685 weeks. This is non logical input of
course (and not GNU compliant). But this isn't a very logical interpretation of this value from
a human perspective.
The parser decided to not be able to recognize weeks, then fallback to hours, interpret up to 2
decimals (compliant with hour parsing), then split the remainder and continue parsing, interpreting
the rest as the input for weeks.
This has been a [known issue for Wikipedia](https://phabricator.wikimedia.org/T10554) since 2007,
but was never reported upstream.
### PHP Version
```plain
PHP 8.4.16 (cli) (built: Dec 16 2025 16:03:34) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.16, Copyright (c) Zend Technologies
with Xdebug v3.4.0, Copyright (c) 2002-2024, by Derick Rethans
with Zend OPcache v8.4.16, Copyright (c), by Zend Technologies
```
### Operating System
macos