Laravel 将时间戳转换为具有特定时区的日期
Laravel convert timestamp into date with specific timezone
我使用以下方法将我的时间戳保存在 Laravel 中。
Carbon::now()->timestamp;
如何将时间戳转换为具有特定时区的特定时间格式(使用 Carbon)?
$unix_time_stamp = "1572095520";
$date = Carbon::createFromTimestamp($unix_time_stamp);
$date->setTimezone('Pacific/Auckland')->format('Y-m-d H:i:s');
我得到的结果不正确,应该是 10 月 27 日
请尝试以下操作。
$unix_time_stamp = '1572095520';
$converted = Carbon::createFromTimestamp($unix_time_stamp,'Pacific/Auckland')
->toDateTimeString();
转到配置 -> app.php 并更改 'timezone' => 'Pacific/Auckland',
我使用以下方法将我的时间戳保存在 Laravel 中。
Carbon::now()->timestamp;
如何将时间戳转换为具有特定时区的特定时间格式(使用 Carbon)?
$unix_time_stamp = "1572095520";
$date = Carbon::createFromTimestamp($unix_time_stamp);
$date->setTimezone('Pacific/Auckland')->format('Y-m-d H:i:s');
我得到的结果不正确,应该是 10 月 27 日
请尝试以下操作。
$unix_time_stamp = '1572095520';
$converted = Carbon::createFromTimestamp($unix_time_stamp,'Pacific/Auckland')
->toDateTimeString();
转到配置 -> app.php 并更改 'timezone' => 'Pacific/Auckland',