Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase current date by 10 days with jQuery

I have an input of type="date". I want to be able to add 10 extra days to it but I do not know how to do that.

I am able to display the current day by using the following:

$('#duedate').val((new Date().toJSON().slice(0,10)));

But how to add 10 days?

like image 252
Saj Avatar asked Oct 31 '25 01:10

Saj


1 Answers

This will work for you:

var date = new Date();
date.setDate(date.getDate() + 10);
$('#duedate').val(date.toJSON().slice(0,10));

Demo

like image 117
martynas Avatar answered Nov 02 '25 14:11

martynas