CalculatorsLesson 172Free preview
Day of the Week
This lesson is part of Web Developer Tools · All levels
Summary
Day of the Week counts the names of days for a specific date, for example for a schedule, archive, or data analysis. JavaScript provides getDay() with 0 for Sunday, while ISO standards use 1 for Monday to 7 for Sunday. Use a pure date and a consistent time zone so the results don't shift one day.
Key points
- JavaScript: 0=Wednesday, 1=Tuesday, up to 6=Saturday
- ISO 8601:1=Monday to 7=Wednesday
- The time zone can shift the date if the clock is not turned.
- Zeller's algorithm can count days without a library.
- The name of the local day can be formatted with Intl.DateTimeFormat
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.