Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery-日期计算_Jquery_Date - Fatal编程技术网

jquery-日期计算

jquery-日期计算,jquery,date,Jquery,Date,我的问题很简单 jQuery('#from').val(jQuery('#to').val()); 我想将jQuery('#from')值设置为jQuery('#to')-28天 目前,日期格式为2014年4月21日 jQuery('to').val()is 04/21/2014 我应该使用什么函数来计算日期?使用好的旧js: var fromDate = new Date($('#from').val() ); var toDate = new Date(); toDate.setDa

我的问题很简单

jQuery('#from').val(jQuery('#to').val());
我想将
jQuery('#from')
值设置为
jQuery('#to')
-28天

目前,日期格式为2014年4月21日

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

我应该使用什么函数来计算日期?

使用好的旧js:

 var fromDate = new Date($('#from').val() );
 var toDate = new Date();
 toDate.setDate(fromDate.getDate() - 28);
 $('#to').val(toDate.toString())
使用好的旧js:

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

向我们展示您的尝试向我们展示您的尝试