JS Built-ins
← Date52 / 120
DategetSecondsbeginner

getSeconds() β€” returns 0

πŸ“– Usage Example
const d = new Date(2024, 0, 15, 12, 30, 45)
d.getSeconds()  // β†’ 45
// returns 0–59

Use getSeconds() to retrieve the seconds component (0–59) of a Date object in local time.

Date.prototype.getSeconds()

When seconds are 0, getSeconds() returns 0.

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

πŸ’‘ Hints (1)
  • β€’ 0 seconds means exactly at the start of a minute