Evalute U-timestamp in createFromFormat as GMT timestamp
未关闭
还没有人认领这个 Issue。
Bug
Extension: date
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.1k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先复现 issue 中的 DateTime::createFromFormat('U e', ...) 示例,并将其与文档中针对 U 的 GMT 行为进行比较。跟踪 createFromFormat 的入口点,确定需要调整的是实现还是文档;当报告的时区偏移差异得到解决并通过验证覆盖时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100