Extracts padded YYYY-MM-DD date string out of the given date object.

Type signature

(date: Date) => string

Examples

toDate(
  new Date(
    "2019-01-15T12:00:00.000Z",
  ),
);
// ⇒ "2019-01-15"
Try in REPL

Questions

  • How to get only the date from a Date object?

TypeScript sourceJavaScript source