2.1.2 • Published 4 years ago

@wertarbyte/skwas-cordova-plugin-datetimepicker v2.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

npm version

skwas-cordova-plugin-datetimepicker

Cordova Plugin for showing a native date, time or datetime picker.

Installation

cordova plugin add skwas-cordova-plugin-datetimepicker

or for latest

cordova plugin add https://github.com/skwasjer/skwas-cordova-plugin-datetimepicker.git

Supported platforms

  • Android 4.4 and higher
  • iOS 9 and higher

Methods

show

show(options)
Show the plugin with specified options.

show(options, successCallback, errorCallback)
Show the plugin with specified options and callbacks.

This was the original way to call the plugin, and is kept for compatibility.

Note: The successCallback and errorCallback respectively will be ignored if the success or error callback is provided on the options argument.

Options

NameTypeDefaultAndroidiOS
modeStringdatedate, time, datetimedate, time, datetimeThe display mode
dateDaterequiredrequiredThe initial date to display
allowOldDatesbooleantrueSupportedSupportedAllow older dates to be selected
allowFutureDatesbooleantrueSupportedSupportedAllow future dates to be selected
minDateDateSupportedSupportedSet the minimum date that can be selected
maxDateDateSupportedSupportedSet the maximum date that can be selected
minuteIntervalint1>= HoneycombSupportedFor minute spinner the number of minutes per step
localeString(user default)-SupportedThe locale to use for text and date/time
okTextString(os default)SupportedSupportedThe text to use for the ok button
cancelTextString(os default)SupportedSupportedThe text to use for the cancel button
clearTextStringSupportedSupportedThe text to use for the clear button
titleTextStringDepends on themeSupportedThe text to use for the dialog title
successFunction(date)-SupportedSupportedThe success callback
cancelFunction()-SupportedSupportedThe cancel callback
errorFunction(err)-SupportedSupportedThe error callback
androidObject{}optionalignoredAndroid specific options

When providing the clearText property, an extra button is shown with intent to clear the current date. When the user taps this button, the success callback will be called with an undefined date. From a UI perspective, this button should be hidden by application code when no date is currently set by omitting the property, but this is up to you.

Android options

NameTypeDefaultDescription
themeintTheme_DeviceDefault_Dialogandroid.R.style theme
is24HourViewbooleantrueUse a 24 hour clock

On Lollipop and upwards the date and time pickers changed to calendar and radial pickers. If you want to use spinners (for example to use minuteInterval), use a built-in android.R.style theme that shows a date and time picker with spinners or read up here how to customize this.

Example

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {

    var myDate = new Date(); // From model.

    cordova.plugins.DateTimePicker.show({
        mode: "date",
        date: myDate,
        success: function(newDate) {
            // Handle new date.
            console.info(newDate);
            myDate = newDate;
        }
    });
}

hide

hide()
Hide the date time picker.

If the picker is currently being shown and a cancel-callback was provided in the options, the callback will be called when the picker is hidden.

Example

cordova.plugins.DateTimePicker.hide();

Changelog

For a list of all changes see here.

Build requirements

  • Cordova 7 and higher
  • Xcode 11 and higher (iOS)

Contributors