Initialize Calendar object on page
Formating date
Calendar supports rich date formatting
It can be used in two ways.
- Set specified format for all operations
format_str can include any of next options
%e [g-] Day of the month without leading zeros (1..31)
%d [gs] Day of the month, 2 digits with leading zeros (01..31)
%j [g-] Day of the year, 3 digits with leading zeros (001..366)
%a [g-] A textual representation of a day, three letters
%W [g-] A full textual representation of the day of the week
%c [g-] Numeric representation of a month, without leading zeros (1..12)
%m [gs] Numeric representation of a month, with leading zeros (01..12)
%b [gs] A short textual representation of a month, three letters (Jan..Dec)
%M [gs] A full textual representation of a month, such as January or March (January..December)
%y [g-] A two digit representation of a year (93..03)
%Y [gs] A full numeric representation of a year, 4 digits (1993..2003)
%% [gs] Char "%"
- Use format only in single get/set operation
Double calendar
For selecting of date range double calendar can be used
- dhtmlxDblCalendar - id of object inside which calendar will be created
- true - force immediately rendering of calendar
Slightly different range ability can be created in standard calendar with usage of setSensitive
Third parameter of constructor allows set different options of calendar.
- dateFrom - minimal allowed date
- dateTo - maximal allowed date
Multilingual Calendar
To add and use different languages in calendar with the ability to switch between them dynamically you need first to define necessary language settings with script
(if no language pack provided with calendar package). Do it this way:
dhtmlxCalendarLangModules = new Array();//create array if it doesn't exist
//define settings for the new language
dhtmlxCalendarLangModules['ru'] = {
langname: 'ru',
dateformat: '%d.%m.%Y',
monthesFNames: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
monthesSNames: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"],
daysFNames: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"],
daysSNames: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"],
weekend: [0, 6],
weekstart: 1,
msgClose: "Закрыть",
msgMinimize: "Свернуть",
msgToday: "Сегодня"
}
//define settings for the new language
dhtmlxCalendarLangModules['de'] = {
langname: 'de',
dateformat: '%d.%m.%Y',
monthesFNames: ["Januar", "Februar", "Mдrz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
monthesSNames: ["Jan", "Feb", "Mдr", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
daysFNames: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
daysSNames: ["So", "Mn", "Dn", "Mt", "Dn", "Fr", "Sa"],
weekend: [0, 6],
weekstart: 1,
msgClose: "SchlieЯen",
msgMinimize: "Drehen",
msgToday: "Heute"
}
When you have necessary languages you can switch between them using loadUserLanguage method and code of the language you used for its definition.
Event(s) in calendar
v.1.0 of dhtmlxCalendar has one event - onclick. You can set event handler using the way common for all dhtmlx components:
yourCalendar.attachEvent("onclick",function(date){
alert("Date set to "+date)
})