How to get the current quarter in year with TypeScript

1 Answer

0 votes
function getCurrentQuarter(date = new Date()) {
  	return Math.floor(date.getMonth() / 3 + 1);
}

console.log(getCurrentQuarter()); 

  
  
  
  
/*
run:
  
3
  
*/

 



answered Apr 11, 2022 by avibootz
...