Jump to content

Time Display Prob


Guest 84inc

Recommended Posts

Hey this is my first post :) and I have a question about display a date a certain # of days from now. I am using it to show a date for when an offer ends that will be 15 days from the current date but I am doing it now and it is saying November 35. I am using the code below to show it and below i have the whole script I am using, any help would be flat out awesome!var date=time.getDate()+15now the whole script:<script language="JavaScript1.2"><!-- Beginvar months=new Array(13);months[1]="January";months[2]="February";months[3]="March";months[4]="April";months[5]="May";months[6]="June";months[7]="July";months[8]="August";months[9]="September";months[10]="October";months[11]="November";months[12]="December";var time=new Date();var lmonth=months[time.getMonth() + 1];var date=time.getDate()+15;var year=time.getYear();if (year < 2000) // Y2K Fix, Isaac Powellyear = year + 1900; // http://onyx.idbsu.edu/~ipowelldocument.write("" + lmonth + " ");document.write(date +", " + year + "");// End --></script>I'm a newbie I know. Sorry, i'm still learning don' think any less of me :)I was just looking through the code and noticed the Y2k script so i am trying to adjust the date prob in the same way but i dont know how to tell it to start a new month and add the right # of days to make it show the # of days after the current day in the proper format, i don't know if the JS knows how to do this or not i am trying to do:if (date > 31)date = date ??????any help? thanks so much...

Link to comment
Share on other sites

Try this instead:

var time = new Date();time.setDate(time.getDate() + 15);

Here is the whole script:

<script language="JavaScript1.2"><!-- Beginvar months=new Array(13);months[1]="January";months[2]="February";months[3]="March";months[4]="April";months[5]="May";months[6]="June";months[7]="July";months[8]="August";months[9]="September";months[10]="October";months[11]="November";months[12]="December";var time=new Date();time.setDate(time.getDate() + 15);var lmonth=months[time.getMonth() + 1];var date=time.getDate();var year=time.getYear();if (year < 2000) // Y2K Fix, Isaac Powellyear = year + 1900; // http://onyx.idbsu.edu/~ipowelldocument.write("" + lmonth + " ");document.write(date +", " + year + "");// End --></script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...