I have seen the example of date range in AnyTime js manual but is there a way to create a time range using AnyTime js?
Thank you.
I have seen the example of date range in AnyTime js manual but is there a way to create a time range using AnyTime js?
Thank you.
The answers mentioned are correct but i would like to elaborate a little. If one wants to have time restrictions along with date restrictions, he/she will need to create two fields and call date and time separately. For eg.
$('#datepicker').AnyTime_picker(
{
earliest: new Date(2014,7,1),
format: "%Y-%m-%d",
latest: new Date(2014,8,8)
}
);
To restrict just based on time, one needs to set the date to a certain date and time to your restricted times. For eg.
$('#timepicker').AnyTime_picker(
{
earliest: new Date(0,0,0,11,0),
format: "%H:%i",
latest: new Date(0,0,0,20,30)
}
);
On the other hand, if one wants to allow users to select any time for days except start date and end date but wants to have a start time on start date and end time on end date, then the following code can be used:
$('#datetimepicker').AnyTime_picker(
{
earliest: new Date(2014,7,1,11,0),
format: "%Y-%m-%d %H:%i",
latest: new Date(2014,8,8,20,30)
}
);
From Documentation:
earliest: new Date(2000,0,1,0,0,0),
format: "%b %e, '%y"
latest: new Date(2099,11,31,23,59,59)
new Date( [Year], [Month], [Day], [Hour!!!], [Minute!!!], [Second!!!]
You only have to set the Date with Time to get a TimeRange.
AnyTime.picker()
uses the format specifier to decide which buttons to display, so if you specify a format that only includes time values (hours, minutes and/or seconds), then you will get a time picker instead of a date picker.