Forum Moderators: open

Message Too Old, No Replies

Javascript Date Script -Anyway to print date +3 days from current date

Would like to display the date 3 days from today on my website

         

tomld2

7:37 pm on Jan 29, 2004 (gmt 0)

10+ Year Member



I have a javascript date script on my site that displays the current date. Is there anyway I can make it display the date plus 3 days. So if today is the 29th, it would instead display Feb. 1st? I pasted the code below. If anyone can tell me how to modify it so it displays 3 days ahead of the current date, I would very much appreciate it.

Thanks!

Script:
=================
<script language="javascript">
<!--

var now = new Date();

// Modify the variables days/months to display in the format
// you wish (eg. 01-12/January-December/Jan-Dec or Sun/Sunday)

var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','june','July','August','Septmeber','October','November','December');

var date = ((now.getDate()<10)? "0" : "")+ now.getDate();

function longyear(number)
{
return (number < 1000)? number + 1900 : number;
}

// Today 3 format = Day - MM/DD/YYYY
today3 = (months[now.getMonth()] + " " + date + ", " + longyear(now.getYear()));

document.write(" " +today3+ " ");

// End -->
</script>

Purple Martin

10:00 pm on Jan 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at this recent thread:
[webmasterworld.com...]