Difference between revisions of "DOM Calendar"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
**day of the week in French | **day of the week in French | ||
**month in French | **month in French | ||
The function toLocalDateString takes an ''options'' object. You can set: | |||
*<code>weekday<code> to one of <code>long</code> <code>short</code> <code>numeric</code> | |||
<pre class=usr> | <pre class=usr> | ||
let today = new Date(); | let today = new Date(); | ||
document.body.innerHTML = ` | document.body.innerHTML = ` | ||
${today.toLocaleDateString('en',{weekday:'long'})} <br> | ${today.toLocaleDateString('en',{weekday:'long'})} <br> | ||
${today.toLocaleDateString('en',{weekday:' | ${today.toLocaleDateString('en',{weekday:'short'})} <br> | ||
`; | `; | ||
</pre> | </pre> |
Revision as of 21:30, 1 January 2022
Display dates as specified
- For today's date show
- day of the week in English
- month in English
- day of the week in French
- month in French
The function toLocalDateString takes an options object. You can set:
weekday
to one of
long
short
numeric
let today = new Date();
document.body.innerHTML = `
${today.toLocaleDateString('en',{weekday:'long'})} <br>
${today.toLocaleDateString('en',{weekday:'short'})} <br>
`;
let today = new Date();
document.body.innerHTML = `
${today.toLocaleDateString('en',{weekday:'long'})} <br>
${today.toLocaleDateString('en',{month:'long'})} <br>
${today.toLocaleDateString('fr',{weekday:'long'})} <br>
${today.toLocaleDateString('fr',{month:'long'})} <br>
`;