我认为,在$Date
变量,你必须是一个Carbon(默认可在Laravel
)对象:
$Date->format('Y-m-d H:i:s');
我们设置timezone
您可以使用其中任何一项:
$Date->timezone = new DateTimeZone('Asia/Singapore');
$Date->timezone = 'Asia/Singapore';
$Date->tz = 'Asia/Singapore';
您也可以设置它从你app/config/app.php
这样的:
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Asia/Singapore',
我不想无礼但为什么你会标记所有的laravel版本?首先你的问题与Laravel无关。可能是因为Carbon在laravel4的作曲家中默认,但laravel3与你的问题无关。 – 2016-03-03 07:09:58