2015-07-10 65 views
1

我使用Laravel5 Carbon函數:從Carbon函數獲取日期Laravel 5

$ carbon_today = Carbon :: today();

DD($ carbon_today)後得到這樣的:

Carbon {#200 ▼ 
    +"date": "2015-07-10 00:00:00" 
    +"timezone_type": 3 
    +"timezone": "UTC" 
} 

而且它是好的。現在我只需要使用CArbon中的日期來輸入變量。嘗試用foreach,

foreach ($carbon_today as $row) { 
    $x= $row['date']; 
    dd($x); 
} 

沒有更迭

+0

$ carbon_today =碳::今日() - >格式( 'Y-M-d G:H:I');解決問題! TNX! – pavlenko

回答

0

你並不需要循環,它只是使用它像

$carbon_today= Carbon::today(); 
return $carbon_today; 

您將得到更新今天$ carbon_today變量

0

試試

$today = Carbon::today();; 
echo $today; 

$today = Carbon::today()->toDateTimeString(); 
echo $today; 

Read More