Easy way to get day number of current quarter?

Chad Johnson picture Chad Johnson · Aug 5, 2009 · Viewed 45.1k times · Source

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 number of the current day of the current quarter?

So right now, August 5, it is day 36 of the third quarter.

If there is no standard way of calculating this, does anyone have a (prefereably PHP-based) algorithm handy?

Answer

Michiel picture Michiel · Feb 24, 2011

How about:

$curMonth = date("m", time());
$curQuarter = ceil($curMonth/3);