JS Built-ins
Dateintermediate

Date Constructor β€” all time components

πŸ“– Usage Example
const d1 = new Date()
const d2 = new Date('2024-01-15')
const d3 = new Date(2024, 0, 15)  // β†’ Jan 15 2024
d3 instanceof Date  // β†’ true

Use new Date() to create a Date object from the current time, a timestamp, a date string, or explicit year/month/day arguments.

Date Constructor

new Date(year, month, day, hours, minutes, seconds, ms) lets you set every component at once.

Challenge: Verify that new Date(2024, 0, 15, 12, 30, 45, 500).getSeconds() returns 45.

πŸ’‘ Hints (1)
  • β€’ The 7-arg constructor is new Date(year, monthIndex, day, hours, minutes, seconds, ms)