public static function convertToDateTime($value)
    {
        if ($value instanceof \DateTime) {
            return $value;
        }

        if (substr($value, -1) == 'Z') {
            $value = substr($value, 0, strlen($value) - 1);
        }

        return new \DateTime($value, new \DateTimeZone('UTC'));
    }
public static function convertToDateTime($value)
    {
        if ($value instanceof \DateTime) {
            return $value;
        }

        if (substr($value, -1) == 'Z') {
            $value = substr($value, 0, strlen($value) - 1);
        }

        return new \DateTime($value, new \DateTimeZone('UTC'));
    }
public static function convertToDateTime ( $ value ) { if ( $ value instanceof \ DateTime ) { return $ value ; } if ( substr ( $ value , - 1 ) == 'Z' ) { $ value = substr ( $ value , 0 , strlen ( $ value ) - 1 ) ; } return new \ DateTime ( $ value , new \ DateTimeZone ( 'UTC' ) ) ; }
Converts a string to a \DateTime object. Returns false on failure.

@param string $value The string value to parse.

@return \DateTime
Converts a string to a \ DateTime object . Returns false on failure .