format(static::FORMAT); } public static function str2time($input) { if (!is_string($input)) { return null; } try { $time = new DateTime($input); if ($time->format(static::FORMAT) !== $input) { return null; } return $time; } catch (Exception $e) { return null; } } public static function time2str(DateTime $time) { return $time->format(static::FORMAT); } }