QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Start of the Day

Returns the start of the day (midnight) for a given date.

  • date
  • start-of-day

Install

npx shadcn@latest add https://quicksnip.dev/r/start-of-the-day.json

This snippet is not verified yet. Review it before use, or help verify it.

Code

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

Usage

const today = new Date();
startOfDay(today); // Returns: Date object for midnight