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

Get the last date in the month of a date

JavaScript

const getLastDate = (d = new Date()) => new Date(d.getFullYear(), d.getMonth() + 1, 0)

TypeScript

const getLastDate = (d = new Date()): Date => new Date(d.getFullYear(), d.getMonth() + 1, 0)