[Home] > Snippets  > Languages  > JavaScript  > Date Time  >  Get the first date in the month of a date

Get the first date in the month of a date

JavaScript

const getFirstDate = (d = new Date()) => new Date(d.getFullYear(), d.getMonth(), 1)

TypeScript

const getFirstDate = (d = new Date()): Date => new Date(d.getFullYear(), d.getMonth(), 1)