Pages

Sunday, September 22, 2013

PHP-Find current quarter for genarating quarterly payments etc.

    $firstday1=date("Y-1-1 00:00:00");
        $lastday1=date("Y-3-31 23:59:59");
        $firstday2=date("Y-4-1 00:00:00");
        $lastday2=date("Y-6-30 23:59:59");
        $firstday3=date("Y-7-1 00:00:00");
        $lastday3=date("Y-9-30 23:59:59");
        $firstday4=date("Y-10-1 00:00:00");
        $lastday4=date("Y-12-31 23:59:59");
        $today = time();
        if( (strtotime($firstday1) <= $today) && ($today<= strtotime($lastday1)))
        {
            $qtr=1;
        }
        elseif( (strtotime($firstday2) <= $today) && ($today <= strtotime($lastday2)))
        {
            $qtr=2;
        }
        elseif( (strtotime($firstday3) <= $today) && ($today <= strtotime($lastday3)))
        {
            $qtr=3;
        }
        elseif( (strtotime($firstday4) <= $today) && ($today <= strtotime($lastday4)))
        {
            $qtr=4;
        }
        echo $qtr;

No comments:

Post a Comment