Forum Moderators: open

Message Too Old, No Replies

How do I show a date for 20 days in JavaScript?

JavaScript date display in 20 day increments

         

rebbew

8:30 pm on Jul 13, 2003 (gmt 0)

10+ Year Member



I need to write a Javascript function that will display a date that does not change for 20 days. On the 21st day, the date again changes to a new date 20 days in the future, and so on. For example "August 18th." ( in that format) displays for 20 days. And then on August 19th, "September 18th" displays for 20 days, etc. I have tried to do this with the various JavaScript date functions, but cannot get it to work. Any suggestions?

tedster

1:32 am on Jul 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld.

How about setting up an array where the array elements are preset "changeover" dates. Then the script would read today's date, cycle through the array elements until it gets a "future" date, and use that first future date it finds to print on the page.

rebbew

2:28 am on Jul 14, 2003 (gmt 0)

10+ Year Member



Thank you. I will give that a try.

g1smd

7:42 pm on Jul 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If this is to be a long term solution then you'll need to know that the same day comes round on the same date only every 28 years; but the solution does then cover all years from 1901 to 2099.