0

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.

kapa
  • 77,694
  • 21
  • 158
  • 175
sarah
  • 103
  • 2
  • 12

3 Answers3

0

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)
        }
        );
user1439090
  • 792
  • 5
  • 12
  • 33
0

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.

Manuel Richarz
  • 1,916
  • 13
  • 27
0

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.

Rais Alam
  • 6,970
  • 12
  • 53
  • 84
Andrew M. Andrews III
  • 1,989
  • 18
  • 23