/** * @param string|int|DateTime $date UTC * * @return \cs\models\Response * integer - unix time */ private static function convertDate($date) { if (is_string($date)) { if (Str::isContain($date, '-')) { return Response::success((new \DateTime($date, new \DateTimeZone('UTC')))->format('U')); } else { return Response::success((int) $date); } } else { if (is_integer($date)) { return Response::success($date); } else { if ($date instanceof DateTime) { return Response::success($date->format('U')); } else { return Response::error('Не верный формат данных'); } } } }
/** * @param string|int|DateTime $date UTC * * @return \cs\models\Response * integer - unix time */ private static function convertDate($date) { if (filter_var($date, FILTER_VALIDATE_INT)) { return Response::success($date); } else { if ($date instanceof DateTime) { return Response::success($date->format('U')); } else { if (is_string($date)) { return Response::success((new \DateTime($date, new \DateTimeZone('UTC')))->format('U')); } else { return Response::error('Не верный формат данных'); } } } }