LoginSignup
7

More than 5 years have passed since last update.

年と月から年度を取得する

Posted at

「年」と「月」から、年度を取得します。
2013年3月であっても、3月決算の会社であれば年度は2012年となります。

function get_financial_year($year, $month, $financial_month){

    if($month > $financial_month){
        return $year;
    } else {
        return $year - 1;
    }
}

2013年3月の年度(3月決算月)は?


echo get_financial_year(2013, 3, 3);

2012

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7