İlk Tarih :
<input type="datetime-local" id="ilktarih" placeholder="ilk tarih"/><br>
Son Tarih :
<input type="datetime-local" id="sontarih" placeholder="son tarih" />
var intervalID;
intervalID = setInterval(tarihsaatBass, 300);
$(document).on('click', '#ilktarih, #sontarih', function (e) {
clearInterval(intervalID);
});
function tarihsaatBass() {
var dt = new Date();
var suankiTarihsaat = dt.getFullYear() + "-" + ('0' + (dt.getMonth() + 1)).slice(-2) + "-" + ('0' + (dt.getDate() +0)).slice(-2) + "T" +('0' + (dt.getHours() + 0)).slice(-2) + ":" + ('0' + (dt.getMinutes() + 0)).slice(-2);
var dt2 = new Date(suankiTarihsaat);
dt2.setDate(dt2.getDate() - 10); // -10 gün öncesi //
var gecmisTarihsaat = dt2.getFullYear() + "-" + ('0' + (dt2.getMonth() + 1)).slice(-2) + "-" + ('0' + (dt2.getDate() +0)).slice(-2) + "T" +('0' + (dt2.getHours() + 0)).slice(-2) + ":" + ('0'+(dt2.getMinutes() + 0)).slice(-2);
$("#sontarih").val(suankiTarihsaat);
$("#ilktarih").val(gecmisTarihsaat);
}
This Pen doesn't use any external CSS resources.