Tuesday, October 3, 2023
 Popular · Latest · Hot · Upcoming
32
rated 0 times [  35] [ 3]  / answers: 1 / hits: 69209  / 15 Years ago, thu, july 23, 2009, 12:00:00

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.


More From » jquery

 Answers
21
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


[#99065] Monday, July 20, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
katharinek

Total Points: 302
Total Questions: 105
Total Answers: 123

Location: Austria
Member since Thu, Jan 7, 2021
3 Years ago
katharinek questions
Sat, Jan 16, 21, 00:00, 3 Years ago
Sat, Dec 5, 20, 00:00, 3 Years ago
Mon, Nov 30, 20, 00:00, 3 Years ago
Fri, Aug 21, 20, 00:00, 3 Years ago
;