时间处理

This commit is contained in:
2025-08-20 11:29:05 +08:00
parent e7cf1dce94
commit 2d2e30faa9
3 changed files with 10 additions and 4 deletions
+7 -1
View File
@@ -100,7 +100,13 @@ class Util
public static function formatDate($value,$key = ['created_at','updated_at'])
{
foreach ($key as $k){
$value[$k]= self::timeTotDate($value[$k]);
// 如果是整数,可能是 UNIX 时间戳
if (is_numeric($value[$k]) && $value[$k] > 0) {
// 检查是否是合理的时间戳范围(1970-2100年)
if ($value[$k] >= 0 && $value[$k] <= 4102444800) {
$value[$k]= self::timeTotDate($value[$k]);
}
}
}
return $value;
}