2016-12-27 98 views
0

當我使用這段代碼,當語言是英語,例如12月,我得到$date_number = 12,但是當我用德語時,我得到了Dezember $date_number= 01。那就是我認爲我需要使用Carbon將月份名稱轉換爲月份的字符串數目,以便我可以使用本地化。任何建議如何解決這個問題?使用Carbon將月份名稱轉換爲字符串編號?

​​

回答

0

這是行得通嗎?

$articles = Articles::whereRaw('MONTH(created_at) ='.Carbon::parse('1975-05-21 22:23:00.123456')->month)->where('approved',1)->get(); 

你可以嘗試設置本地:

setlocale(LC_TIME, 'German'); 
echo $dt->formatLocalized('%A %d %B %Y'); 

Carbon::setLocale('de'); 

退房此鏈接: http://carbon.nesbot.com/docs/

相關問題