Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经在我的 laravel 应用程序中安装了 Carbon。但是没有找到任何会在 php 中给出与 gmdate 类似的结果的函数。
我试过以下但它没有帮助我:
echo gmdate("YmdH", (time() + 19800)).'<br/>'; echo Carbon::createFromTimeStampUTC('YmdH', (time() + 19800));
我想使用 Carbon 实现与 gmdate 在 laravel 中提供的类似功能
可以将时区作为第三个参数传递createFromFormat()
createFromFormat()
createFromFormat ( string $format , string $time [, DateTimeZone $timezone ] )
所以你可以做这样的事情:
$date = Carbon::createFromFormat('Y-m-d H:i:s', $timestamp, 'Europe/London'); $date->setTimezone('UTC');