Calendar Example

Question: How do I determine the week day for a given date?

Answer: To determine the week day for a given date, you set this date in a

Date()
object, and then get the week day using the
Date.getDay()
method:
d=new Date(); d.setDate(1);

d.setYear(yyyy);
d.setMonth(mm);
d.setDate(dd);

ww=d.getDay();
if (ww==0) wDay="Sunday";
if (ww==1) wDay="Monday";
if (ww==2) wDay="Tuesday";
if (ww==3) wDay="Wednesday";
if (ww==4) wDay="Thursday";
if (ww==5) wDay="Friday";
if (ww==6) wDay="Saturday";

Copyright © 1996-2018, JavascriptFAQ.net.