Easy way to get day number of current quarter?

后端 未结 9 1958
暖寄归人
暖寄归人 2021-01-31 18:39

PHP provides ways to get the number of the current day of the month (date(\'j\')) as well as the number of the current day of the year (date(\'z\')). Is there a way to get the n

9条回答
  •  伪装坚强ぢ
    2021-01-31 19:35

    You can use Carbon it has easy modifiers for getFirstOf{Month,Year,Quarter}()

    copy()->firstOfQuarter();
    
    //calculate the difference in days and add 1 to correct the index
    $dayOfQuarter = $now->diffInDays($firstOfQuarter) + 1;
    

提交回复
热议问题