QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Format Date

Formats a date in 'YYYY-MM-DD' format.

  • date
  • format

Install

npx shadcn@latest add https://quicksnip.dev/r/format-date.json

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

Code

const formatDate = (date) => date.toISOString().split('T')[0];

Usage

formatDate(new Date(2024, 11, 10)); // Returns: '2024-12-10'