Daniel Moody
Daniel Moody

Reputation: 45

Javascript get day of week from date

I am creating a reservation application in one of my classes. In the app, a user is trying to create a recurring reservation by giving a start date and end date and a day of the week they want the reservation. I want to return a list of dates that they have reservations on; here's an example

Start Date: 02/01/2015 End Date: 03/01/2015 Days of the Week: Monday and Wednesday.

In this example, I want to return all the Mondays and Wednesdays during this time. I would like to do this in Javascript.

Upvotes: 0

Views: 589

Answers (1)

Brayden G
Brayden G

Reputation: 93

Loop through the dates using:

tomorrow.setDate(today.getDate()+1);

And check if the day of the week is monday or wednesday using:

tomorrow.getDay()

Upvotes: 0

Related Questions