Announcement

Collapse
No announcement yet.

When I add days, my day name does not display correctly. Someone help me?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • When I add days, my day name does not display correctly. Someone help me?

    I am trying to add 10 days to the current date at my site and display it. When I use the script below, it adds the date correctly, but the name of the day is not correct, only the date is. Can someone correct my code below?

    Doug

    <form name=myForm2>
    <input type=button value="Loading..." name=clock></form>
    <SCRIPT LANGUAGE="JavaScript"><!--
    function runClock(){
    theTime = window.setTimeout("runClock()", 1000);
    d = new Date();
    day = d.getDay();
    mon = d.getMonth();
    date = d.getDate();
    year = d.getYear();
    hr = d.getHours();
    min = d.getMinutes();
    sec = d.getSeconds();
    diff = 10
    date2 = date;
    date+=diff;
    monthdays = new Array();
    monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
    if(date>monthdays[mon]){date-=monthdays[mon] ; mon+=1}
    if (mon>12) {mon-=12 ; year+=1}
    if(year<1000){year=(""+(year+11900)).substring(1,5 );}
    else{year=(""+(year+10000)).substring(1,5);}
    if(hr==0){ap=" AM";hr=12}
    else if(hr <= 11){ap=" AM"}
    else if(hr == 12){ap=" PM";hr=12}
    else if(hr >= 13){ap=" PM";hr-=12}
    if(min <= 9){min="0"+min}
    if(sec <= 9){sec="0"+sec}
    zmon=new Array();
    zmon=["January","February","March","April","May","Ju ne", "July","August","September","October","Novembe r"," December","January"];
    zday=new Array();
    zday=["Sunday","Monday","Tuesday","Wednesday","Thursday" ,"Friday","Saturday"];
    document.myForm2.clock.value="The new date will be "+zday[day]+", "+zmon[mon]+" "+date+", "+year+"";}
    runClock();
    //--></script>
Working...
X