Jquery / Javascript - Add years to date variable

后端 未结 6 1477
耶瑟儿~
耶瑟儿~ 2021-02-19 06:05

I have a small trouble that would be great to have some help with. I am creating a small form that I want to take a current date formatted \'dd/mm/yyyy\' and add a

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 06:36

    var dt = new Date($("#startdate").val());
    
    var updateDate = dt.setDate(dt.getFullYear() + $("#registerfor").val());
    
    var dd = updateDate.getDate();
    var mm = updateDate.getMonth();
    var y = updateDate.getFullYear();
    
    var someFormattedDate = dd + '/'+ mm + '/'+ y;
    console.log(someFormattedDate);
    

提交回复
热议问题