How to get the quarter from a date in JavaScript

1 Answer

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

console.log(getQuarterFromADate(new Date('2023-04-10'))); 

  
  
  
  
/*
run:
  
2
  
*/

 



answered Apr 11, 2022 by avibootz

Related questions

...