Formats a date as a string in YYYY-MM-DD format (or custom separator).
YYYY-MM-DD
The Date object to format.
Optional separator to use between year, month, and day (default: -).
-
A formatted date string.
formatDate(new Date(2025, 6, 23)); // '2025-07-23'formatDate(new Date(2025, 6, 23), '/'); // '2025/07/23' Copy
formatDate(new Date(2025, 6, 23)); // '2025-07-23'formatDate(new Date(2025, 6, 23), '/'); // '2025/07/23'
Formats a date as a string in
YYYY-MM-DD
format (or custom separator).