JS Built-ins
← Date102 / 120
DatetoDateStringbeginner

toDateString() β€” includes year 2024

πŸ“– Usage Example
const d = new Date(2024, 0, 15)
d.toDateString()  // β†’ 'Mon Jan 15 2024'

Use toDateString() to get a human-readable string of the date portion of a Date object in local time.

Date.prototype.toDateString()

Regardless of locale, the output always includes the 4-digit year.

Challenge: Verify that new Date(2024, 0, 15).toDateString().includes('2024') is true.

πŸ’‘ Hints (1)
  • β€’ The year is always present in the output of toDateString()