Solved

handlings dates in javascript

Posted on 2012-03-19
6
223 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
[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
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

691 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