• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

handlings dates in javascript

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
jecommera
Asked:
jecommera
2 Solutions
 
Gurvinder Pal SinghCommented:
check this

var d=new Date();
var milliseconds = d.getTime() + (90*24*60*60*1000);
document.write(new Date(milliseconds));
0
 
MrunalCommented:
This returns full date:

<script type="text/javascript">
var myDate=new Date();
myDate.setDate(myDate.getDate()+90);
alert(myDate);
</script>
0
 
jecommeraAuthor Commented:
Can I get it as just month and date

thanks
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Gurvinder Pal SinghCommented:
var d=new Date();
var newDate = new Date( d.getTime() + (90*24*60*60*1000) );
document.write( newDate.getMonth() + " " + newDate.getDate());
0
 
MrunalCommented:
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
 
HonorGodCommented:
This article may also be of interest: http://e-e.com/A_484-Can-I-have-a-date.html
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now