Jump to content

Recommended Posts

Well I've made a mess of things, I've seemed to compensate for somethings but forgot to compensate for the end of month. How can I take the code below and use it to Advance a month plus adjust the number of the day that will be shown. So lets say for example. Today, its October 31, 2010

 

In 2 days it will be November 2, 2010. The way I managed to mangle this together it will Show October 33, 2010. I'm so tired, and it's been over a month since I played with this code, so I need a fresh pair of eyes and some ideas to help me out.

 

var FutureMonth = 0;
var FutureDays = 2;
var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate()+FutureDays;
var sup = "";
if (curr_date == 1 || curr_date == 21 || curr_date ==31){sup = "st";}
else if (curr_date == 2 || curr_date == 22){sup = "nd";}else if (curr_date == 3 || curr_date == 23){sup = "rd";}
else{sup = "th";}
var curr_month;
var curr_year;
if((d.getMonth()+FutureMonth) > 12){
var diff_month = d.getMonth()+FutureMonth-12;
    curr_month = diff_month;
    curr_year = d.getFullYear()+1;
}else{
curr_month = d.getMonth()+FutureMonth;curr_year = d.getFullYear();
}
document.getElementById("TheFutureDate1").innerHTML =  m_names[curr_month] + " " + curr_date + "<SUP>"+ sup + "</SUP>";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.