[Home] > Snippets  > Languages  > JavaScript  > Date Time  >  Get the current quarter of a date

Get the current quarter of a date

JavaScript

const getQuarter = (d = new Date()) => Math.ceil((d.getMonth() + 1) / 3)

TypeScript

const getQuarter = (d = new Date()): number => Math.ceil((d.getMonth() + 1) / 3)