I have to add the current time with another one.
For example, the time now is 10:30 on 21st July 2011.
I want to book a vehicle for today at 17:00, but 10:30 + $minHours < 17:00 which means that I cannot make the booking.
Here is my code:
var d = new Date();
var curr_day = d.getDay();
var curr_date = d.getDate();
var hours = d.getHours();
var minutes = d.getMinutes();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
a = d_names[curr_day] + ', '
+ curr_date + ' '
+ m_names[curr_month] + ' '
+ curr_year;
t1 = document.getElementById('min_hr');
if(a == e.value)
{
alert("please call reservation to make a booking for collection in the next 24 hours");
return false;
}
else
{
return true;
}
Try this.
Check the properties of
Dateinstance here Date – MDN Docs, especially the getters and setters there.If you want to set the hours use
The signature of the method is
Code for your exact requirement is this.