user3486682
user3486682

Reputation: 5

jquery - date calculation

My question is simple.

jQuery('#from').val(jQuery('#to').val());

I want to set the jQuery('#from') value to jQuery('#to') - 28 days.

For now, the format of date is mm/dd/yyyy ex) 04/21/2014

jQuery('#to').val() is 04/21/2014

what function should I use to calculate the date?

Upvotes: 0

Views: 3088

Answers (1)

T McKeown
T McKeown

Reputation: 12847

use good old js:

 var fromDate = new Date($('#from').val() );
 var toDate = new Date();
 toDate.setDate(fromDate.getDate() - 28);
 $('#to').val(toDate.toString())

Upvotes: 4

Related Questions