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

Initialize the current date but set time to midnight

JavaScript

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

TypeScript

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