update store model

This commit is contained in:
2025-12-10 12:56:37 +08:00
parent 2eab592858
commit 2741dcb3e9
+14
View File
@@ -74,4 +74,18 @@ class Store extends Model
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
]; ];
/**
* 获取标准时区字符串
* 将 UTC 偏移值(如 +8)转换为标准时区格式(如 '+08:00'
*
* @return string 标准时区字符串,可用于 Carbon 和 DateTime
*/
public function getTimezoneString(): string
{
$offset = $this->timezone ?? 0;
$sign = $offset >= 0 ? '+' : '-';
$absOffset = abs($offset);
return sprintf('%s%02d:00', $sign, $absOffset);
}
} }