lundi 29 juin 2015

PHP Compare DateTimeZone Objects

Is this the only way to compare a DateTimeZone Object to a given Timezone?

    $dateNow = new \DateTime('now');
    $tz = $dateNow->getTimezone();
    $this->assertEquals($tz->getName(), $tz->listIdentifiers(\DateTimeZone::UTC)[0]);

Neither comparing two objects nor comparing the constants works. By the way, what are the DateTimeZone constants used for?

Aucun commentaire:

Enregistrer un commentaire