Difference between revisions of "DOM Calendar"

From ProgZoo
Jump to navigation Jump to search
Line 1: Line 1:
<pre id='shellbody' data-qtp='clicky'></pre>
<pre id='shellbody' data-qtp='clicky'></pre>
==Display a list of dates==
==Display dates as specified==
<div class=qu data-width=300>
<div class=qu data-width=300>
*You can display Mon to Sunday
*Show today's date, day of the week.
<pre class=test>
{expr:[{id:'total',prop:"value"}],
actions:[{id:'recalculate',method:"click"},{id:'quantity',value:"2"},{id:'recalculate',method:"click"},]}
</pre>
<pre class=usr>
<pre class=usr>
let firstDate = new Date();
let today = new Date();
for(let i=0;i<6*7;i++){
document.body.innerText = `
  let d = document.createElement('div');
${today.toLocaleDateString('en',{weekday:'long'})} <br>
  let dy = new Date(firstDate.getTime() + 1000*60*60*24*i);
`;
  d.innerText = `${dy}`;
  document.body.append(d);
}
</pre>
</pre>


<pre class=ans>
<pre class=ans>
let today = new Date();
document.body.innerText = `
${today.toLocaleDateString('en',{weekday:'long'})} <br>
${today.toLocaleDateString('en',{month:'long'})} <br>
${today.toLocaleDateString('fr',{weekday:'long'})} <br>
${today.toLocaleDateString('fr',{month:'long'})} <br>
`;
</pre>
</pre>
</div>
</div>

Revision as of 21:24, 1 January 2022


Display dates as specified

  • Show today's date, day of the week.
let today = new Date();
document.body.innerText = `
${today.toLocaleDateString('en',{weekday:'long'})} <br>
`;
let today = new Date();
document.body.innerText = `
${today.toLocaleDateString('en',{weekday:'long'})} <br>
${today.toLocaleDateString('en',{month:'long'})} <br>
${today.toLocaleDateString('fr',{weekday:'long'})} <br>
${today.toLocaleDateString('fr',{month:'long'})} <br>
`;