datetimepicker手册
来源:
https://xdsoft.net/jqplugins/datetimepicker/
https://github.com/xdan/datetimepicker
Full options list
Name | default | Descr | Ex. |
---|---|---|---|
lazyInit | false | Initializing plugin occurs only when the user interacts. Greatly accelerates plugin work with a large number of fields | |
parentID | 'body' | Attach datetimepicker to this element, which can be either a selector or a DOM/JQuery element |
|
value | null | Current value datetimepicker. If it is set, ignored input.value |
|
lang | en | Language i18n ar - Arabic az - Azerbaijanian (Azeri) bg - Bulgarian bs - Bosanski ca - Català ch - Simplified Chinese cs - Čeština da - Dansk de - German el - Ελληνικά en - English en-GB - English (British) es - Spanish et - "Eesti" eu - Euskara fa - Persian fi - Finnish (Suomi) fr - French gl - Galego he - Hebrew (עברית) hr - Hrvatski hu - Hungarian id - Indonesian it - Italian ja - Japanese ko - Korean (한국어) kr - Korean lt - Lithuanian (lietuvių) lv - Latvian (Latviešu) mk - Macedonian (Македонски) mn - Mongolian (Монгол) nl - Dutch no - Norwegian pl - Polish pt - Portuguese pt-BR - Português(Brasil) ro - Romanian ru - Russian se - Swedish sk - Slovenčina sl - Slovenščina sq - Albanian (Shqip) sr - Serbian Cyrillic (Српски) sr-YU - Serbian (Srpski) sv - Svenska th - Thai tr - Turkish uk - Ukrainian vi - Vietnamese zh - Simplified Chinese (简体中文) zh-TW - Traditional Chinese (繁體中文) |
|
format | Y/m/d H:i | Format datetime. More Also there is a special type of «unixtime» |
|
formatDate | Y/m/d | Format date for minDate and maxDate |
|
formatTime | H:i | Similarly, formatDate . But for minTime and maxTime |
|
step | 60 | Step time |
|
closeOnDateSelect | 0 |
| |
closeOnWithoutClick | true |
| |
validateOnBlur | true | Verify datetime value from input, when losing focus. If value is not valid datetime, then to value inserts the current datetime |
|
timepicker | true |
| |
datepicker | true |
| |
weeks | false | Show week number |
|
theme | 'default' | Setting a color scheme. Now only supported default and dark theme |
|
minDate | false |
| |
maxDate | false |
| |
startDate | false | calendar set date use starDate |
|
defaultDate | false | if input value is empty, calendar set date use defaultDate |
|
defaultTime | false | if input value is empty, timepicker set time use defaultTime |
|
minTime | false |
| |
maxTime | false |
| |
allowTimes | [] |
| |
mask | false | Use mask for input. true - automatically generates a mask on the field 'format', Digit from 0 to 9, set the highest possible digit for the value. For example: the first digit of hours can not be greater than 2, and the first digit of the minutes can not be greater than 5 | |
opened | false | ||
yearOffset | 0 | Year offset for Buddhist era | |
inline | false | ||
todayButton | true | Show button "Go To Today" | |
defaultSelect | true | Highlight the current date even if the input is empty | |
allowBlank | false | Allow field to be empty even with the option validateOnBlur in true | |
timepickerScrollbar | true | ||
onSelectDate | function(){} |
| |
onSelectTime | function(current_time,$input){} | ||
onChangeMonth | function(current_time,$input){} | ||
onChangeYear | function(current_time,$input){} | ||
onChangeDateTime | function(current_time,$input){} | ||
onShow | function(current_time,$input){} | ||
onClose | function(current_time,$input){} |
| |
onGenerate | function(current_time,$input){} | trigger after construct calendar and timepicker | |
withoutCopyright | true | ||
inverseButton | false | ||
scrollMonth | true | ||
scrollTime | true | ||
scrollInput | true | ||
hours12 | false | ||
yearStart | 1950 | Start value for fast Year selector | |
yearEnd | 2050 | End value for fast Year selector | |
roundTime | round | Round time in timepicker, possible values: round, ceil, floor |
|
dayOfWeekStart | 0 | Star week DatePicker. Default Sunday - 0. Monday - 1 ... | |
className | |||
weekends | [] |
| |
disabledDates | [] | Disbale all dates in list |
|
allowDates | [] | Allow all dates in list |
|
allowDateRe | [] | Use Regex to check dates |
|
disabledWeekDays | [] | Disable days listed by index |
|
id | |||
style | |||
ownerDocument | document | The ownerDocument object for the datetimepicker to properly attach events and calc position (iframe support). | |
contentWindow | window | The contentWindow object that contains the datetimepicker to properly attach events (iframe support). |
Methods
show
Show Datetimepicker
$('#input').datetimepicker();
$('button.somebutton').on('click', function () {
$('#input').datetimepicker('show');
});
hide
Hide Datetimepicker
$('#input').datetimepicker();
$(window).on('resize', function () {
$('#input').datetimepicker('hide');
});
toggle
Sgow/Hide Datetimepicker
$('#input').datetimepicker();
$('button.trigger').on('click', function () {
$('#input').datetimepicker('toggle');
});
destroy
Destroy datetimepicker
$('#input').datetimepicker();
$('#input').datetimepicker('destroy');
reset
Reset datetimepicker's value
$('#input').datetimepicker();
$('#input').val('12/01/2006');
$('#input')
.datetimepicker('show')
.datetimepicker('reset')
validate
Validate datetimepicker's value
$('#input').datetimepicker();
$('#input').datetimepicker(validate)
setOptions
Set datetimepicker's options
$('#input').datetimepicker({format: 'd.m.Y'});
$('#input').datetimepicker('setOptions', {format: 'd/m/Y'});
//or
$('#input').datetimepicker({format: 'd/m/Y'});
getValue
Get current datetimepicker's value (Date object)
$('#input').datetimepicker();
$('button.somebutton').on('click', function () {
var d = $('#input').datetimepicker('getValue');
console.log(d.getFullYear());
});