Solved

handlings dates in javascript

Posted on 2012-03-19
6
208 Views
Last Modified: 2012-03-19
Hi,

I am practicing some JS and have the following question:

An invoice is due and payable in 90 days. Write a function that will display that
date.

I have got as far as the following code however of course this just returns a number.

var now = new Date();
invoice_date = now.getDate()+90;
document.write(invoice_date);

Can someone advise the best way to manage this?
0
Comment
Question by:jecommera
6 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37737699
check this

var d=new Date();
var milliseconds = d.getTime() + (90*24*60*60*1000);
document.write(new Date(milliseconds));
0
 
LVL 22

Expert Comment

by:Mrunal
ID: 37737704
This returns full date:

<script type="text/javascript">
var myDate=new Date();
myDate.setDate(myDate.getDate()+90);
alert(myDate);
</script>
0
 

Author Comment

by:jecommera
ID: 37737743
Can I get it as just month and date

thanks
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 37737773
var d=new Date();
var newDate = new Date( d.getTime() + (90*24*60*60*1000) );
document.write( newDate.getMonth() + " " + newDate.getDate());
0
 
LVL 22

Assisted Solution

by:Mrunal
Mrunal earned 250 total points
ID: 37737816
Here it is:

<script type="text/javascript">
var myDate=new Date();
myDate.setDate(myDate.getDate()+90);

document.write(myDate + "<br/>");
document.write(myDate.getMonth() + "<br/>");
document.write(myDate.getDate());

</script>

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 37738510
This article may also be of interest: http://e-e.com/A_484-Can-I-have-a-date.html
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question