Skip to main content

setValue()

selects a date in the calendar

setValue(value: Date | Date[] | string | string[]): boolean;

Parameters:

  • value: Date | Date[] | string | string[] - the date to select

Returns:

Defines, whether a date has been successfully added into the calendar.

Example

// sets the current date
calendar.setValue(new Date());

// sets the current date as an array of Date value
calendar.setValue([new Date()]);

// sets a date as a string
calendar.setValue("30/05/19");

// sets a date as an array of string value
calendar.setValue(["30/05/19"]);

//sets dates as an array of Date values(for the range mode)
calendar.setValue([new Date(2019,05,03), new Date(2019,05,19)]);

//sets dates as an array of string values(for the range mode)
calendar.setValue(["03/06/19", "15/06/19"]);

Related sample: Calendar. Preset selected date

note

Please note that the format of date in the Calendar is defined by the dateFormat option. So, check that you've set the format of date you want to use in the calendar both in the setValue() method and in the dateFormat property. Otherwise, the default format ("%d/%m/%y") will be used.