How to add min to current date/specific date and compare both dates in javascript?
Session contain time(min).Either positive or Negative.I want to add that time in current date.If positive,it should get added.If negative,it should get reduced from that.I want to do it from javascript.1 :
var Time = '<%=Session["Time"]%>';
var d1 = new Date(),
d2 = new Date(d1);
d2.setMinutes(d1.getMinutes() + Time);
alert(d2);
When I am writing like this (above code) I am getting invalid date.
var Time = '<%=Session["Time"]%>';
var d1 = new Date(),
d2 = new Date(d1);
d2.setMinutes(d1.getMinutes() + 30);
alert(d2);
When I am writing like this (above code) I am getting proper date.Is it a right way to add min to current date.
2 : I am selecting date from date picker,that gives me date like this '03/30/2016',I have another dropdownlist for selecting hours and min. I want to add hours and time in selected date.Hours is in 24.Time in 60.
var d = new Date('03/30/2016');
d.setHours(d.getHours() + 17);
d.setMinutes(d.getMinutes() + 54);
alert(d);
Is it a right way to do?
3 : I want compare both date d and d2. d should be greater than d2.If not,should show message to user.