Calendar Date Matrix Generator
Generate calendar date matrix grids for any month. Configurable first day, locale, weekday format. Export as JSON, CSV, or copy the visual grid.
About
A date matrix is a two-dimensional array where each row represents one calendar week and each column maps to a weekday. Generating one correctly requires resolving the offset between the first day of the target month and the configured week start (Monday or Sunday). Errors in this offset produce misaligned grids that cascade across every rendered week. This tool computes the matrix for any month of any year, tagging each cell with a type - current, previous, or next - so padding days from adjacent months are unambiguous. It supports locale-aware weekday headers via Intl.DateTimeFormat and outputs raw JSON identical to the createDateMatrix contract, plus CSV and copyable visual grids.
The underlying calculation determines d0, the weekday index of the first of the month, then walks backward by (d0 − s) mod 7 days, where s is 0 for Sunday-start or 1 for Monday-start. It always produces 6 full weeks (42 cells) for layout consistency. Note: the locale parameter only affects weekday header labels, not calendar logic. Pro tip: if you need ISO week numbers, the Monday-start matrix aligns directly with ISO 8601 weeks.
Formulas
The matrix start date is computed by finding how many padding days from the previous month are needed before the first of the target month:
where d0 is the weekday index of the 1st of the month (0 = Sunday, 6 = Saturday) and s is the start-of-week index (0 for Sunday, 1 for Monday). The grid start date is then:
The total grid always contains 6 × 7 = 42 cells. Each cell is classified:
Weekday headers are generated via Intl.DateTimeFormat(locale, { weekday: weekdayFormat }). The formatter is applied to a reference week starting from a known Monday (e.g., 2024-01-01) and reordered based on firstDay.
Reference Data
| Locale Code | Language | Short Mon | Short Tue | Short Wed | Short Thu | Short Fri | Short Sat | Short Sun | Typical First Day |
|---|---|---|---|---|---|---|---|---|---|
| en-US | English (US) | Mon | Tue | Wed | Thu | Fri | Sat | Sun | Sunday |
| en-GB | English (UK) | Mon | Tue | Wed | Thu | Fri | Sat | Sun | Monday |
| de-DE | German | Mo | Di | Mi | Do | Fr | Sa | So | Monday |
| fr-FR | French | lun. | mar. | mer. | jeu. | ven. | sam. | dim. | Monday |
| es-ES | Spanish | lun | mar | mié | jue | vie | sáb | dom | Monday |
| it-IT | Italian | lun | mar | mer | gio | ven | sab | dom | Monday |
| pt-BR | Portuguese (BR) | seg. | ter. | qua. | qui. | sex. | sáb. | dom. | Sunday |
| ja-JP | Japanese | 月 | 火 | 水 | 木 | 金 | 土 | 日 | Sunday |
| ko-KR | Korean | 월 | 화 | 수 | 목 | 금 | 토 | 일 | Sunday |
| zh-CN | Chinese (Simplified) | 周一 | 周二 | 周三 | 周四 | 周五 | 周六 | 周日 | Monday |
| ru-RU | Russian | пн | вт | ср | чт | пт | сб | вс | Monday |
| ar-SA | Arabic (Saudi) | الاثنين | الثلاثاء | الأربعاء | الخميس | الجمعة | السبت | الأحد | Sunday |
| hi-IN | Hindi | सोम | मंगल | बुध | गुरु | शुक्र | शनि | रवि | Sunday |
| tr-TR | Turkish | Pzt | Sal | Çar | Per | Cum | Cmt | Paz | Monday |
| pl-PL | Polish | pon. | wt. | śr. | czw. | pt. | sob. | niedz. | Monday |
| nl-NL | Dutch | ma | di | wo | do | vr | za | zo | Monday |
| sv-SE | Swedish | mån | tis | ons | tors | fre | lör | sön | Monday |
| da-DK | Danish | man. | tir. | ons. | tor. | fre. | lør. | søn. | Monday |
| th-TH | Thai | จ. | อ. | พ. | พฤ. | ศ. | ส. | อา. | Sunday |
| he-IL | Hebrew | יום ב׳ | יום ג׳ | יום ד׳ | יום ה׳ | יום ו׳ | שבת | יום א׳ | Sunday |