Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use jQuery/JS to determine the DAY OF WEEK

Is there a method using either JavaScript or jQuery to determine what day of the week it is? For instance, if the date a user picks in the box is a Sunday, I can alert them.

like image 641
Jason Avatar asked Sep 10 '25 02:09

Jason


1 Answers

new Date().getDay();  //0=Sun, 1=Mon, ..., 6=Sat

See also: Javascript Date Object on MDN.

Word of Caution: This returns day of week on the browser. Because the earth is not flat, the day of the week for some users might be different from the day of the week for your server. This may or may not be relevant to your project...

If you are doing a lot of date work, you may want to look into JavaScript date libraries like Datejs or Moment.js

like image 69
Kip Avatar answered Sep 12 '25 17:09

Kip