# Disable date picker based on time of day on custom form element

**URL:** <https://forum.wixstudio.com/t/disable-date-picker-based-on-time-of-day-on-custom-form-element/66505>\
**Category:** Ask the community\
**Tags:** code, wix\
**Created:** [December 27, 2024, 4:10pm UTC](https://forum.wixstudio.com/t/disable-date-picker-based-on-time-of-day-on-custom-form-element/66505 "2024-12-27T16:10:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Haehnel](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/nathan_haehnel/32/102412_2.png) [@Nathan\_Haehnel](https://forum.wixstudio.com/u/Nathan_Haehnel)\
**Post date:** [December 27, 2024, 4:10pm UTC](https://forum.wixstudio.com/t/disable-date-picker-based-on-time-of-day-on-custom-form-element/66505/1 "2024-12-27T16:10:30Z")

</div>

I have created a custom form for scheduling requests. Users can click the day they want an appointment. They can do same day requests but up to a certain time. How can I disable the current day on a date picker at a specific time of day? (Example: No same day appointment requests can be done after 8:00am.)

Using Wix Editor - This is the code I have tried:

```javascript
let myDatePicker = $w('#datePicker1');
let today = new Date();

function isTimeWithinRange(startTime, endTime) {
	const currentHour = new Date().getHours();
	const currentMinute = new Date().getMinutes();
	return currentHour >= startTime && currentHour < endTime (currentHour === startTime && currentMinute >= 0)(currentHour === endTime && currentMinute < 60);
}
function updateDatePickerState() {
	let disableDatePicker = isTimeWithinRange(8, 16);
	if (disableDatePicker) {
		myDatePicker.disabledDateRanges = [new Date()];
	} else {
		myDatePicker.disabledDateRanges = [];
		}
	}

$w.onReady(() => updateDatePickerState());

```

I am getting the error “Type ‘Date’ is missing the following properties from type ‘DateRange’: startDate, endDate” on line 12 for [new Date()];

I am pretty beginner at coding and know enough to cause some trouble 😉 Hoping someone could help find a solution or offer another suggestion to implement time of day date disabling. Thank you SO much for any help!
