Skip to content

Commit a42bf93

Browse files
committed
Fixed GH-10447: 'p' format specifier does not yield 'Z' for 00:00
1 parent 00be6e1 commit a42bf93

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ext/date/php_date.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t
716716
/* timezone */
717717
case 'I': length = slprintf(buffer, sizeof(buffer), "%d", localtime ? offset->is_dst : 0); break;
718718
case 'p':
719-
if (!localtime || strcmp(offset->abbr, "UTC") == 0 || strcmp(offset->abbr, "Z") == 0) {
719+
if (!localtime || strcmp(offset->abbr, "UTC") == 0 || strcmp(offset->abbr, "Z") == 0 || strcmp(offset->abbr, "GMT+0000") == 0) {
720720
length = slprintf(buffer, sizeof(buffer), "%s", "Z");
721721
break;
722722
}

ext/date/tests/gh10447.phpt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug GH-10447 ('p' format specifier does not yield 'Z' for 00:00)
3+
--FILE--
4+
<?php
5+
$date = new \DateTimeImmutable('2023-01-25T00:00:00+00:00');
6+
echo $date->format('Y-m-d\TH:i:sp'), "\n";
7+
8+
$date = new \DateTimeImmutable('2023-01-25T00:00:00-00:00');
9+
echo $date->format('Y-m-d\TH:i:sp'), "\n";
10+
?>
11+
--EXPECT--
12+
2023-01-25T00:00:00Z
13+
2023-01-25T00:00:00Z

0 commit comments

Comments
 (0)