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

Get the first date in the month of a date

JavaScript version

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

TypeScript version

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