Questions on JavaScript Date & Time

Use these 20 self-contained questions to check how well you understand JavaScript Date objects, local and UTC getters, month numbering, timestamps, setters, validation, ISO strings, date arithmetic, Intl formatting and time-zone handling. No external question engine is required.

How to use this practice set: answer all questions first, then select Check Answers. Your score and a short explanation for every question will appear. You can change answers and check again, or reset the quiz and start over.
1. What does new Date() create when called with no arguments?
new Date() creates a Date object representing the current instant.
2. Which method returns the four-digit year from a Date in local time?
getFullYear() returns the full year such as 2026. getYear() is legacy and should not be used for normal year values.
3. What range does getMonth() return?
getMonth() is zero-based: January is 0 and December is 11.
4. What does getDate() return?
getDate() returns the day number within the month. getDay() is the weekday method.
5. What does getDay() return for Sunday?
getDay() uses 0 for Sunday through 6 for Saturday.
6. Which method returns the local hour from 0 to 23?
getHours() returns the hour in the local time zone, from 0 through 23.
7. What does new Date(2026, 0, 15).getMonth() return?
The numeric Date constructor also uses zero-based months, so 0 means January.
8. What date is produced by new Date(2026, 12, 1)?
Date components normalize overflow. Month 12 is one month after December 2026, so the result is January 1, 2027.
9. What does Date.now() return?
Date.now() returns a numeric timestamp in milliseconds since 1970-01-01T00:00:00Z.
10. What does date.getTime() return for a valid Date object?
getTime() returns the Date object's timestamp in milliseconds.
11. What does toISOString() return?
toISOString() formats the instant in UTC, typically like 2026-09-12T02:30:00.000Z.
12. Which expression moves a Date forward by seven calendar days?
setDate() accepts overflow and mutates the Date, so adding 7 to getDate() moves it forward seven calendar days.
13. How can you make an independent copy of an existing Date named original?
new Date(original.getTime()) creates a new Date object with the same timestamp. A simple assignment would point both variables to the same object.
14. Which test reliably detects an Invalid Date object named d?
Invalid Date produces NaN from getTime(), so Number.isNaN(d.getTime()) is a reliable check.
15. Which API is best suited to locale-aware date and time formatting?
Intl.DateTimeFormat provides locale-aware formatting and supports options for date parts, time parts, and time zones.
16. Which value is an IANA time-zone identifier that Intl.DateTimeFormat can use?
Asia/Kolkata is an IANA time-zone identifier. IANA names are preferred when a real geographic time zone is required.
17. Why is UTC normalization useful when calculating differences between date-only calendar values?
Local days can be 23 or 25 hours around daylight-saving transitions. Normalizing date-only values to UTC midnights avoids that local-hour distortion.
18. How is the ISO date-only string "2026-09-12" interpreted by the JavaScript Date parser?
The standard ISO date-only form YYYY-MM-DD is interpreted as midnight UTC. This can display as the previous local date in time zones west of UTC.
19. Which expression returns the number of days in February for a year stored in year?
Day 0 of March means the final day of February. Its getDate() value is therefore 28 or 29.
20. Why can setMonth() produce a surprising date when the current day is 29, 30, or 31?
Date normalizes invalid component combinations. For end-of-month work, it is often safer to set the day to 1 before changing the month, then choose the intended day.
Score: not checked yet.

What to review next Top ↑

If a question was difficult, use the related tutorial links below, review the example, and then retry the quiz. The goal is to understand why an answer is correct rather than memorize the score.




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer