get startdate and enddate for current quarter php

前端 未结 19 1673
悲哀的现实
悲哀的现实 2020-12-29 10:58

I am trying to set a start date and end date by the quarter.

For example, I am working on a reporting system where i need to report data for quarter 1, quarter 2, qu

19条回答
  •  我在风中等你
    2020-12-29 11:22

    A simpler way to get the start/end of the current quarter in dates:

    $qtr_start = date("Y-".(ceil(date("n")/3))."-01");
    

    Then, just add 3 months in the correct place to get the end:

    $qtr_end = date("Y-".(ceil(date("n")/3)+3)."-01");
    

    Just my two cents.

提交回复
热议问题