Subtracting days/months/years from a Date object

后端 未结 4 1768
我寻月下人不归
我寻月下人不归 2021-01-04 09:06
var inputDate     = \'20/4/2010\'.split(\'/\');
var dateFormatted = new Date(parseInt(inputDate[2]), parseInt(inputDate[1]), parseInt(inputDate[0]));

var expiryDate         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-04 09:19

    var currentDate = new Date(year,month,day);
    var expiryDate = new Date();
    expiryDate.setTime(currentDate.getTime() + (3 * 365 * 24 * 60 * 60 * 1000));
    

    using the number of seconds past 1970 is fine for this :-) oh, you have more rules. well after that you will still have to check for those cases...

提交回复
热议问题