Link to home
Start Free TrialLog in
Avatar of jecommera
jecommeraFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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?
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

check this

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

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

ASKER

Can I get it as just month and date

thanks
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial