facebook / facebook/hhvm

DateTime::createFromFormat not handling Timezone

Open
#6,331 1 comment 0 reactions 0 assignees View on GitHub
php5 incompatibility php7 incompatibility probably easy
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

When creating a DateTime with createFromFormat it ignores the timezone specified within the format.

``` php
date_default_timezone_set('UTC');
$time = DateTime::createFromFormat('Y-m-d\TH:i:s.uP', '2015-03-22T11:42:25.943Z');
var_dump($time->getTimezone()->getName());

$time = DateTime::createFromFormat('Y-m-d\TH:i:s.uP', '2015-03-22T11:42:25.943+02:00');
var_dump($time->getTimezone()->getName());
```

**PHP 5.5**

```
Runtime: PHP 5.5.9-1ubuntu4.9 with Xdebug 2.2.3:

string(1) "Z"
string(6) "+02:00"
```

**HHVM**

```
Runtime: HHVM 3.9.1

string(3) "UTC"
string(3) "UTC"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.