Bug #81267 [NEW]: Instantiating DateTime with unix timestamps does not set UTC as Timezone
| From: | heiglandreas@php.net | Date: | Fri, 16 Jul 2021 13:45:41 +0000 |
| Subject: | Bug #81267 [NEW]: Instantiating DateTime with unix timestamps does not set UTC as Timezone | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-235082@lists.php.net to get a copy of this message | ||
From: heiglandreas
Operating system: 3v4l.org
PHP version: 8.0.8
Package: Date/time related
Bug Type: Bug
Bug description:Instantiating DateTime with unix timestamps does not set UTC as Timezone
Description:
------------
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).
Why?
According to https://en.wikipedia.org/wiki/Unix_time 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 :
* https://en.wikipedia.org/wiki/Unix_time
* https://3v4l.org/f7bBe
Test script:
---------------
<?php
$f = new DateTimeImmutable('@1234567');
var_dump($f->getTimezone());
Expected result:
----------------
object(DateTimeZone)#2 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
Actual result:
--------------
object(DateTimeZone)#2 (2) {
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=81267&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81267&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81267&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81267&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81267&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81267&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81267&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81267&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81267&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81267&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81267&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81267&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81267&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81267&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81267&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81267&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81267&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81267&r=mysqlcfg