my.datePicker opens a date selection dialog that allows users to pick dates and times in various formats. By default, the current date and time are used if not manually selected.
my.datePicker({
format: 'yyyy-MM-dd',
currentDate: '2016-10-10',
startDate: '2016-10-9',
endDate: '2017-10-9',
success: (res) => {
my.alert({
title: 'datePicker response: ' + JSON.stringify(res)
});
},
});
| Property | Type | Required | Description |
|---|---|---|---|
format | String | No | The returned date format. |
currentDate | String | No | The date and time initially selected. By default, the current time date and time are used. |
startDate | String | No | Minimum date and time. |
endDate | String | No | Maximum date and time. |
success | Function | Yes | The callback function for a successful API call. |
fail | Function | Yes | The callback function for a failed API call. |
complete | Function | Yes | The callback function used when the API call is completed. This function is always executed no matter the call succeeds or fails. |
The returned date formats include:
yyyy-MM-dd (default)HH:mmyyyy-MM-dd HH:mmyyyy-MMyyyy| Property | Type | Description |
|---|---|---|
date | String | The selected date. |
| Error Code | Description | Solution |
|---|---|---|
11 | The user cancels the operation and no action is required. | The user cancelled the operation and no action is required. |
currentDate, startDate, or endDate are not specified, the current date and time are used by defaultformat parameter determines the date picker's mode and return formatfail callback with error code 11