[go: up one dir, main page]

Skip to content
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

Dates Created from Strings with Timezone Offsets Aren't Properly Formatted When Using 'p' #10447

Closed
dustinwilson opened this issue Jan 25, 2023 · 3 comments

Comments

@dustinwilson
Copy link

Description

The following code:

<?php
$date = new \DateTimeImmutable('2023-01-25T00:00:00+00:00');
echo $date->format('Y-m-d\TH:i:sp');

Resulted in this output:

2023-01-25T00:00:00+00:00

But I expected this output instead:

2023-01-25T00:00:00Z

PHP Version

8.2.1

Operating System

MacOS Monterey (12.6.3)

@hormus
Copy link
hormus commented Jan 26, 2023

Currently support p is with timezone type 3 or type 2 "UTC" or explicit "Z" https://php.watch/versions/8.0/date-utc-p-format :)

<?php

date_default_timezone_set('Europe/Berlin');
$date = new \DateTime('2023-01-25T00:00:00');
echo $date->format('p');

?>

For missing offset is default offset:
Expected result: +01:00
For explicit offset +00:00
Expected result: +00:00
Or !localtime
a6e3ce4#diff-975ac482adc74b487c6ac9d8dde32153e4b8a803ef8ec41e8d6594f0a042db69R715
Expected result with p and timezone UTC
$date2 = new DateTime('now', new DateTimeZone('UTC'));
echo $date2->format('p'); // Z

@derickr
Copy link
Member
derickr commented Jan 26, 2023

@damianwadley Why did you change this to "Verified" — I see no triage report as to why this issue occurs, and whether this is an issue at all.

derickr added a commit to derickr/php-src that referenced this issue Jan 26, 2023
@damianwadley
Copy link
Member

I assumed it had been verified because the "needs triage" was removed. Though I did briefly confirm that "p" wasn't outputting just Z which it's documented to do.

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

6 participants
@derickr @dustinwilson @Girgias @damianwadley @hormus and others