[php-src] Issue #11215: The Problem about Unixtime Convert
| From: | stevennight | Date: | Wed, 10 May 2023 09:25:01 +0000 |
| Subject: | [php-src] Issue #11215: The Problem about Unixtime Convert | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244416@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11215
Author: stevennight
### Description
# The following code:
```php
<?php
#date_default_timezone_set("PRC");
date_default_timezone_set("Asia/Shanghai");
echo strtotime('1988-04-18') . PHP_EOL;
echo strtotime('1988-04-19') . PHP_EOL;
echo strtotime('1988-04-19') - strtotime('1988-04-18') . PHP_EOL;
echo strtotime('1988-04-17') . PHP_EOL;
echo strtotime('1988-04-18') . PHP_EOL;
echo strtotime('1988-04-18') - strtotime('1988-04-17') . PHP_EOL;
echo strtotime('1988-04-11') . PHP_EOL;
echo strtotime('1988-04-10') . PHP_EOL;
echo strtotime('1988-04-11') - strtotime('1988-04-10') . PHP_EOL;
```
# Resulted in this output:
577292400
577378800
86400
**577209600
577292400
82800**
576691200
576604800
86400
# But I expected this output instead:
The convert from '1988-04-18' to timestamp maybe wrong when I set the timezone to PRC or
Asia/Shanghai.(Other timezone like 'Asia/Hong_kong', 'Asia/Tokyo', it seem
running well with this test data) The interval between 1998-04-17 and 1998-04-18 only 82800
seconds(23 hours). I try to convert it with java or mysql are got the timestamp is
'577296000' instead of '577292400'.
When I try to convert with '2023-05-10', the result is correct, it's same to mysql
result.
I'm very confused, can you help me please? thanks.
### PHP Version
7.4.27 But it seem Other version with this problem too, I checked on https://onlinephp.io with 8.2.6 and other.
### Operating System
_No response_