In this article, we will learn how to get a financial year or fiscal year using a given date in Javascript.
Here is the code to get a financial year or fiscal year using a given date in Javascript.
<script>
function getCurrentFinancialYear() {
var financial_year = "";
var today = new Date();
if ((today.getMonth() + 1) <= 3) {
financial_year = (today.getFullYear() - 1) + "-" + today.getFullYear()
} else {
financial_year = today.getFullYear() + "-" + (today.getFullYear() + 1)
}
return financial_year;
}
alert(getCurrentFinancialYear());
</script>
I hope this article will help you to understand how to get a financial year using a given date in Javascript.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments