[Home] >  Date Time >  Initialize the current date but set time to midnight

Initialize the current date but set time to midnight

JavaScript version

const midnightOfToday = () => new Date(new Date().setHours(0, 0, 0, 0));

TypeScript version

const midnightOfToday = (): Date => new Date(new Date().setHours(0, 0, 0, 0));