JS Built-ins
← Date101 / 120
DatetoDateStringbeginner

toDateString() β€” returns a string

πŸ“– 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()

Returns a human-readable date string like "Mon Jan 15 2024". The exact format is engine-dependent.

Challenge: Verify that typeof new Date(2024, 0, 15).toDateString() returns 'string'.

πŸ’‘ Hints (1)
  • β€’ toDateString() is locale-independent but engine-defined β€” test for type and content, not exact format