mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 13:32:41 +08:00
format_datetime() use Carbon::parse()
This commit is contained in:
@@ -574,13 +574,13 @@ function last_query($all = false)
|
||||
|
||||
function format_datetime($datetime, $format = 'Y-m-d H:i')
|
||||
{
|
||||
if ($datetime instanceof \Carbon\Carbon) {
|
||||
return $datetime->format($format);
|
||||
try {
|
||||
$carbonTime = \Carbon\Carbon::parse($datetime);
|
||||
$carbonTime->format($format);
|
||||
} catch (\Exception) {
|
||||
do_log("Invalid datetime: $datetime", 'error');
|
||||
return $datetime;
|
||||
}
|
||||
if (is_numeric($datetime) && $datetime > strtotime('1970')) {
|
||||
return date($format, $datetime);
|
||||
}
|
||||
return $datetime;
|
||||
}
|
||||
|
||||
function nexus_trans($key, $replace = [], $locale = null)
|
||||
|
||||
Reference in New Issue
Block a user