src/Node/Date.php
public function toDateTime(\DateTimeZone $timeZone = null): \DateTime
    {
        if (null === self::$utc) {
            self::$utc = new \DateTimeZone('UTC');
        }

        $date = \DateTime::createFromFormat('!Y-m-d', $this->getValue(), $timeZone ?: self::$utc);
        if (!$date instanceof \DateTime) {
            $date = \DateTime::createFromFormat('!Y-m-d', (new \DateTime())->format('Y-m-d'), $timeZone ?: self::$utc);
        }

        if ($date->getOffset() !== 0) {
            $date->setTimezone(self::$utc);
        }

        return $date;
    }
public function toDateTime(\DateTimeZone $timeZone = null): \DateTime
    {
        if (null === self::$utc) {
            self::$utc = new \DateTimeZone('UTC');
        }

        $date = \DateTime::createFromFormat('!Y-m-d', $this->getValue(), $timeZone ?: self::$utc);
        if (!$date instanceof \DateTime) {
            $date = \DateTime::createFromFormat('!Y-m-d', (new \DateTime())->format('Y-m-d'), $timeZone ?: self::$utc);
        }

        if ($date->getOffset() !== 0) {
            $date->setTimezone(self::$utc);
        }

        return $date;
    }
public function toDateTime ( \ DateTimeZone $ timeZone = null ) : \ DateTime { if ( null === self :: $ utc ) { self :: $ utc = new \ DateTimeZone ( 'UTC' ) ; } $ date = \ DateTime :: createFromFormat ( '!Y-m-d' , $ this -> getValue ( ) , $ timeZone ? : self :: $ utc ) ; if ( ! $ date instanceof \ DateTime ) { $ date = \ DateTime :: createFromFormat ( '!Y-m-d' , ( new \ DateTime ( ) ) -> format ( 'Y-m-d' ) , $ timeZone ? : self :: $ utc ) ; } if ( $ date -> getOffset ( ) !== 0 ) { $ date -> setTimezone ( self :: $ utc ) ; } return $ date ; }
Always returns a DateTime in UTC.  Use the time zone option to inform this class
that the value it holds is localized and should be converted to UTC.

@param \DateTimeZone $timeZone

@return \DateTime
Always returns a DateTime in UTC . Use the time zone option to inform this class that the value it holds is localized and should be converted to UTC .