<?php private static function parseDateTime($value, string $format): \DateTimeImmutable { if ($value instanceof \DateTimeImmutable) { return $value; } if ($value instanceof \DateTime) { return \DateTimeImmutable::createFromMutable($value); } if (\is_numeric($value)) { return \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $value)); } if (!\is_scalar($value)) { throw new InvalidFormatException("Cannot convert non-scalar value to date/time"); } if (!$result = \DateTimeImmutable::createFromFormat($format, $value)) { throw new InvalidFormatException("Cannot parse '{$value}' as a date/time using the format '{$format}'"); } return $result; }
You have javascript disabled. You will not be able to edit any code.