<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Function to get dates of quarters]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=2129</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=2129&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Function to get dates of quarters.]]></description>
		<lastBuildDate>Sun, 29 May 2011 15:41:18 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Function to get dates of quarters]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=9296#p9296</link>
			<description><![CDATA[<p>Hi Guys</p><p>Mucking about modules at the moment, and have just written a versatile function to calculate start/end dates of quarters. With some adjustment to fit naming standards etc. it might be useful to include in date_functions.inc at some point. Hope someone finds it useful!<br />Pete</p><div class="codebox"><pre><code>/**
 * Get last quarter start and end dates for today. Eg. 13/12/2010 = 1/10/2009, 31/12/2009
 * @param array $qtr_dates Referenced array of quarter dates (0=start, 1=end)
 * @param int $num_qtrs How many quarters back/forward (default 0 = this quarter)
 */
function get_quarter_dates(&amp;$qtr_dates, $num_qtrs = 0) {
    // work out the last quarter dates, and store in the qtr_dates array
    include_once($path_to_root . &quot;/includes/date_functions.inc&quot;);
    // 1. Get current month (number)
    $this_month = date(&#039;m&#039;);
    //$this_month = 1; TEST
    // 2. Calculate the start month for this quarter.
    $this_qtr = intval(($this_month - 1)/3) * 3 + 1;
    // 3. Subtract 3 months from this quarter start date to get last quarter
    $qtr_dates[0] = add_months(__date(date(&#039;Y&#039;),$this_qtr,01),$num_qtrs*3);
    // 4. Add two months and get last day of that month for end of last quarter.
    $qtr_dates[1] = end_month((add_months($qtr_dates[0],2)));
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (p2409)]]></author>
			<pubDate>Sun, 29 May 2011 15:41:18 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=9296#p9296</guid>
		</item>
	</channel>
</rss>
