Dear JavaScript Users,
I have been dabbling in JavaScript as a side project for my own interests. I have recently run into a problem that is definately workable, but at this point it's solution seems to be horribly time consuming. Maybe one of you folks can help.
I am writing a web page that will contain Monday's and Friday's date of each new week. I am doing this through javaScripts getDate() etc... methods to access system times and dates. Unfortunately this involves a whole lot of control statements.
Here is how I am attempting to do this.
if the day of the week is equal to 1 then Monday is the date I'm looking for.
if the day of the week is equal to 2 then Monday-1 is the date I'm looking for
I add and subtract numbers to adjust the date until the new week starts over and a new set of numbers can replace Monday's and Friday's date.
but when I start adding numbers to dates that exceed 28, 29, 30, and 31 (according to which month it is) I get into having dates that are 33, 34 , 35 etc.
having special instances for February and then the months that end in 30 and 31.
Does anyone see a more simple way for me to do this.
any help is completely appreicated
have a good one
I have been dabbling in JavaScript as a side project for my own interests. I have recently run into a problem that is definately workable, but at this point it's solution seems to be horribly time consuming. Maybe one of you folks can help.
I am writing a web page that will contain Monday's and Friday's date of each new week. I am doing this through javaScripts getDate() etc... methods to access system times and dates. Unfortunately this involves a whole lot of control statements.
Here is how I am attempting to do this.
if the day of the week is equal to 1 then Monday is the date I'm looking for.
if the day of the week is equal to 2 then Monday-1 is the date I'm looking for
I add and subtract numbers to adjust the date until the new week starts over and a new set of numbers can replace Monday's and Friday's date.
but when I start adding numbers to dates that exceed 28, 29, 30, and 31 (according to which month it is) I get into having dates that are 33, 34 , 35 etc.
having special instances for February and then the months that end in 30 and 31.
Does anyone see a more simple way for me to do this.
any help is completely appreicated
have a good one