have js date function to get today's date, need tomorrow's date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fwaisfeld
    New Member
    • Apr 2012
    • 1

    have js date function to get today's date, need tomorrow's date

    Hello i am in need of some help with this JS function. I am using a script which gets Today's date, and i am looking to get Tomorrow's date. I need some help. I will show you what i have and please let me know what i need to change to get the date of Tomorrow.

    Thank you very much for your time.

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    
    var now = new Date();
     
    
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
     
    
    var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
     
    
    var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
     
    
    function fourdigits(number) {
        return (number < 1000) ? number + 1900 : number;
                                    }
    
    today =  days[now.getDay()] + ", " +
             months[now.getMonth()] + " " +
             date + ", " +
             (fourdigits(now.getYear())) ;
     
    
    document.write(today);
     
    
    </script>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    the function fourdigits() is superfluous, use Date.getFullYea r(). tomorrows date can be set either by calling Date.setDate() with an incremented date number or by creating a new date via new Date(year, month, day [hour, minute, second]) using Date’s getter methods. note that inexistent days are wrapped to the next month.

    Comment

    Working...