public static function createDateTime($timestamp = null, $timezone = null)
{
$timezone = static::createTimeZone($timezone);
if ($timestamp === null) {
return Carbon::now($timezone);
}
if ($timestamp instanceof \DateTimeInterface) {
return $timestamp;
}
if (is_string($timestamp)) {
return new \DateTime($timestamp, $timezone);
}
if (is_numeric($timestamp)) {
return Carbon::createFromTimestamp($timestamp, $timezone);
}
throw new \InvalidArgumentException('timestamp is not valid');
}