[php-src] Issue #11017: date() function is one hour off for America/Mexico_City timezone
| From: | jjriv | Date: | Tue, 04 Apr 2023 20:33:42 +0000 |
| Subject: | [php-src] Issue #11017: date() function is one hour off for America/Mexico_City timezone | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244098@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11017
Author: jjriv
### Description
See below. when the timezone is set to America/Mexico_City and using the IntlDateFormatter parse()
function to create a timestamp, the date() function is one hour off. The correct time should be
midnight. This appears to be correct in older versions of PHP:
https://3v4l.org/5ha27
The following code:
```php
<?php
$locale = "es_MX";
$shortDatePattern = "dd/MM/yy";
$in_date = "4/4/23";
$timezone = "America/Mexico_City";
date_default_timezone_set($timezone);
$fmt = new IntlDateFormatter($locale,IntlDateFormatter::SHORT,IntlDateFormatter::NONE);
$fmt->setPattern($shortDatePattern);
$timestamp = $fmt->parse($in_date);
echo gmdate('Y-m-d H:i:s', $timestamp) . "\n";
echo date('Y-m-d H:i:s', $timestamp) . "\n";
echo $timestamp . "\n";
echo date_default_timezone_get() . "\n";
```
Resulted in this output:
```
2023-04-04 05:00:00
2023-04-03 23:00:00
1680584400
America/Mexico_City
```
But I expected this output instead:
```
2023-04-04 05:00:00
2023-04-04 00:00:00
1680584400
America/Mexico_City
```
### PHP Version
8.1.13
### Operating System
_No response_