Carbon - get first day of month

前端 未结 2 604
囚心锁ツ
囚心锁ツ 2020-12-29 19:18

I am using carbon but trying to get the first day of the month so I can run a report from the beginning of the month till the current day.

    $date = [
             


        
2条回答
  •  囚心锁ツ
    2020-12-29 19:43

    Try as

    $start = new Carbon('first day of this month');
    

    CARBON DOCS Refer #Testing Aids

    If you already have Carbon object and want to find first day of month for that object you can try as,

    $startDate = Carbon::now(); //returns current day
    $firstDay = $startDate->firstOfMonth();  
    

提交回复
热议问题