|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81267 Instantiating DateTime with unix timestamps does not set UTC as Timezone
Submitted: 2021-07-16 13:45 UTC Modified: 2021-07-16 13:52 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 8.0.8 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2021-07-16 13:45 UTC]
Currently creating a new DateTime(Immutable) Object using a timestamp does set the timezone as +00:00 (Type 1).

Expected outcome would be to have the timestamp be set to UTC (type 3).


According to the unix timestamp is always thought to be a representation of a DateTime in UTC. Having the timezone set to a simple offset does not reflect that. Even though the Unix timestamp has its own way of handling leap seconds and even though there are thoughts on coupling the unix timestamp to a (not yet generally used) "International time" (which would be UTC without leap seconds) the timestamp is generally considered to be a UTC representation, not just of offset +00:00.

See :


Test script:

$f = new DateTimeImmutable('@1234567');

Expected result:
object(DateTimeZone)#2 (2) {
  string(3) "UTC"

Actual result:
object(DateTimeZone)#2 (2) {
  string(6) "+00:00"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-16 13:52 UTC]
-Status: Open +Status: Not a bug
 [2021-07-16 13:52 UTC]
This is for BC reasons, and this issue tracker is also not the right places, as this is parsed by timelib:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 19:01:32 2024 UTC