Evalute U-timestamp in createFromFormat as GMT timestamp
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
echo DateTime::createFromFormat('U e', '1730597400 America/Toronto')->format('U');
Resulted in this output:
1730615400
It's 5 hours more than the input timestamp.
But I expected this output instead:
1730597400
The difference matches the timezone offset.
But documentation on createFromFormat about U says:
Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
GMT is specified, so I expect the timestamp to be constant whatever is the timezone.
I.E. I expect DateTime::createFromFormat('U e', '1730597400 America/Toronto') to be equivalent to:
$date = DateTime::createFromFormat('U', '1730597400');
$date->setTimezone(new DateTimeZone('America/Toronto'));
PHP Version
PHP 8.3.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the DateTime::createFromFormat('U e', ...) example from the issue and compare it with the documented GMT behavior for U. Trace the createFromFormat entry point and determine whether the implementation or documentation needs adjustment; done means the reported timezone-offset discrepancy is resolved and covered by verification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100