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?
Find and get quarter from date by formula Select a blank cell which next to the date, here I select C1, and type this formula =ROUNDUP(MONTH(A1)/3,0) into it, then press Enter key to get the relative quarter.
In SQL Server, you can use DATEPART(QUARTER,whn) and YEAR(whn) . In Oracle, you can use TO_CHAR(whn,'Q') and TO_CHAR(whn,'YYYY') for the quarter and year. In PostgreSQL, you can use EXTRACT(QUARTER FROM whn) and EXTRACT(YEAR FROM whn) . In Access, you can use DatePart("q", whn) and YEAR(whn) .
How about:
$curMonth = date("m", time()); $curQuarter = ceil($curMonth/3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With