Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the date 30 days from today

i need to calculate the date from thirty days using Date in javascript

var now = new Date();

Example:

if today is the 13 February 2013, 30 days later is the 15 March 2013. so something that is different from 30DaysLaterMonth = ActualMonth+1.

I hope my question is clear.. :) thanks everybody!

like image 807
Jayyrus Avatar asked May 25 '12 18:05

Jayyrus


2 Answers

var now = new Date(); 
now.setDate(now.getDate() + 30);
like image 142
Kenny Thompson Avatar answered Nov 14 '22 09:11

Kenny Thompson


I think its better for you to use Datejs

Datejs is an open-source JavaScript Date Library.

or you can do it own:

var cur = new Date(),
    after30days = cur.setDate(cur.getDate() + 30);
like image 20
thecodeparadox Avatar answered Nov 14 '22 07:11

thecodeparadox