简体   繁体   中英

Add 7 days to existing date

Hi I have this input with my products date posted:

<input type="text" id="count" hidden="true" value="{{$product->created_at}}"/>

I want to add 7 days to this date. This is my jQuery code:

 <script type="text/javascript">

 var count = $("#count").val();

   $(".clock")
   .countdown(count, function(event) {
    $(this).text(
      event.strftime('%Hh %Mmin %Ssek')
    );
  });
 </script>

It shows the current date but I want to add 7 more days. Can u help me ?

If #count contains the date you would like to work with, try the following:

var inputDate = new Date($('#count').val());
inputDate.setDate( inputDate.getDate() + 7 );
console.log(inputDate);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM