Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

Posted on 2001-07-11
Medium Priority
2,667 Views
Hi,

I need a sample code for date addition.

E.g

{12/07/2001} + 200 = {28/01/2002}

Pls help urgently

regards
tridib
0
Question by:tridib
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 4

Expert Comment

ID: 6275926
<Script>
var g=new Date(2001,7,12)
g.setDate(g.getDate()+200)
</script>

Good Luck...:)
0

Accepted Solution

rongreen earned 200 total points
ID: 6277863

<SCRIPT LANGUAGE="JavaScript"><!--
function asDays(ddmmyy,days) {
// parse ddmmyy for day, month, year
var dateArray = ddmmyy.split('/');
sdate = new Date(dateArray[2],dateArray[1]-1,dateArray[0]);

// add the number of days as milleseconds
var odate = new Date(sdate.getTime() + (days * 86400000));

// return value
return (odate.getMonth()+1) + '/' + odate.getDate() + '/' + (odate.getYear() + 1900);
}

alert( asDays("12/7/2001",200) ); // gives 1/27/2002
//--></SCRIPT>
0

LVL 1

Expert Comment

ID: 6806574
No response to Proposed Answer, assume Expert served the need here and am finalizing this today.  In the event Asker returns with additional needs here, please respond.

Moondancer
Community Support Moderator @ Experts Exchange
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
###### Suggested Courses
Course of the Month8 days, 1 hour left to enroll