JS Built-ins
← Date53 / 120
DategetSecondsbeginner

getSeconds() β€” returns 59

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

59 is the maximum seconds value.

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

πŸ’‘ Hints (1)
  • β€’ Seconds range from 0 to 59; 60 would roll over to the next minute