Jump to content

financial year calculation in php


Recommended Posts

Hello everyone

I want Show Some Recorded according financial year

For Example from 01-04-2016 to 31-3-2017

01-04-2017 to 31-03-2018

my Code

 

$pst = date('Y');
$pt = date('Y', strtotime('+1 year'));

$sql="SELECT *FROM mytable where date BETWEEN CAST('$pst-04-01' AS DATE) AND CAST('$pt-03-31' AS DATE)";

 

Anyone Can explain how i done this

Link to post
Share on other sites
  • 2 weeks later...
Done


<?php

$pst = date('m');


if($pst>4) {

$y=date('Y');

echo $dtt=$y."-04-01<br/>";

$pt = date('Y', strtotime('+1 year'));

echo $ptt=$pt."-03-31";

}

else {

$y=date('Y', strtotime('-1 year'));

echo $dtt=$y."-04-01<br/>";

$pt =date('Y');

echo $ptt=$pt."-03-31";

}

?>


Edited by Tejpal
Link to post
Share on other sites
  • 4 years later...

function get_finacial_year_range() {

    $year = date('Y');

    $month = date('m');

    if($month<4){

        $year = $year-1;

    }

    $start_date = date('d/m/Y',strtotime(($year).'-04-01'));

    $end_date = date('d/m/Y',strtotime(($year+1).'-03-31'));

    $response = array('start_date' => $start_date, 'end_date' => $end_date);

    return $response;

}

Link to post
Share on other sites
  • Funce locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...