Skip to content

Timezone ID '+00:00' resulting in abnormal php notice #52

Description

@ohartl

When passing a Timezone of '+00:00' (which is valid in normal PHP), while using timecop, it throws an abnormal php notice. This can lead to an exit of the programm depending on your error_reporting setting.

--TEST--
Check timezone '+00:00' being allowed
--SKIPIF--
<?php
$required_func = array("timecop_freeze");
include(__DIR__."/tests-skipcheck.inc.php");
--INI--
date.timezone=America/Los_Angeles
timecop.func_override=1
--FILE--
<?php
$dt1 = new \DateTime('@0', new \DateTimeZone('+00:00'));
var_dump($dt1->format("Y-m-d H:i:s.uP"));

timecop_freeze(0);
$dt2 = new \DateTime('@0', new \DateTimeZone('+00:00'));
var_dump($dt2->format("Y-m-d H:i:s.uP"));
--EXPECT--
string(32) "1970-01-01 00:00:00.000000+00:00"
string(32) "1970-01-01 00:00:00.000000+00:00"

Output of the test:

========OUT========
string(32) "1970-01-01 00:00:00.000000+00:00"

Notice: date_default_timezone_set(): Timezone ID '+00:00' is invalid in ... on line 6
string(32) "1970-01-01 00:00:00.000000+00:00"
========DONE========

========EXP========
string(32) "1970-01-01 00:00:00.000000+00:00"
string(32) "1970-01-01 00:00:00.000000+00:00"
========DONE========

========DIFF========
002+
003+ Notice: date_default_timezone_set(): Timezone ID '+00:00' is invalid in ... on line 6
========DONE========

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions