By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

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

P: 1
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.

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2.  
  3.  
  4. var now = new Date();
  5.  
  6.  
  7. var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  8.  
  9.  
  10. var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
  11.  
  12.  
  13. var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
  14.  
  15.  
  16. function fourdigits(number) {
  17.     return (number < 1000) ? number + 1900 : number;
  18.                                 }
  19.  
  20. today =  days[now.getDay()] + ", " +
  21.          months[now.getMonth()] + " " +
  22.          date + ", " +
  23.          (fourdigits(now.getYear())) ;
  24.  
  25.  
  26. document.write(today);
  27.  
  28.  
  29. </script>
  30.  
Apr 1 '12 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
the function fourdigits() is superfluous, use Date.getFullYear(). 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.
Apr 1 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.