我認爲,在$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