laravel----------carbon時間類的使用介紹

echo Carbon::today();       // 對象 2018-04-17 00:00:00
echo Carbon::tomorrow(); // 對象 2018-04-18 00:00:00
echo Carbon::yesterday();// 對象 2018-04-16 00:00:00

echo Carbon::today()->toDateTimeString();       // 字符串 2018-04-17 00:00:00
echo Carbon::yesterday()->toDateTimeString();// 字符串 2018-04-16 00:00:00
echo Carbon::tomorrow()->toDateTimeString(); // 字符串 2018-04-18 00:00:00

echo Carbon::today()->toDateString();       // 字符串 2018-04-17
echo Carbon::yesterday()->toDateString();// 字符串 2018-04-16
echo Carbon::tomorrow()->toDateString(); // 字符串 2018-04-18spa

 

echo Carbon::now()->startOfDay()->timestamp;              // 1523980800
echo Carbon::now()->endOfDay()->timestamp;               // 1524067199
echo Carbon::now()->startOfDay()->toDateTimeString(); // 2018-04-18 00:00:00
echo Carbon::now()->endOfDay()->toDateTimeString();  // 2018-04-18 23:59:59
對象

echo Carbon::now()->startOfWeek()->timestamp;             // 1523808000
echo Carbon::now()->endOfWeek()->timestamp;              // 1524412799
echo Carbon::now()->startOfWeek()->toDateTimeString();// 2018-04-16 00:00:00
echo Carbon::now()->endOfWeek()->toDateTimeString();// 2018-04-22 23:59:59
字符串

相關文章
相關標籤/搜索