I have a datetime-local input box in my ionic 2 app but I want to show the minutes in 30 min interval only, that is only 0 or 30 (like 9.00 or 9.30). I read about steps but could not find for minutes. Is there a way to achieve it ?
The picker then displays scrollable columns that can be used to individually select years, months, days, hours and minute values. The DateTime component is similar to the native <input type="datetime-local"> element, however, Ionic's DateTime component makes it easy to display the date and time in a preferred format, and manage the datetime values.
Datetimes are similar to the native input elements of type datetime-local, however, Ionic's Datetime component makes it easy to display the date and time in a preferred format, and manage the datetime values.
ISO 8601 Datetime Format: YYYY-MM-DDTHH:mmZ Ionic uses the ISO 8601 datetime format for its value. The value is simply a string, rather than using JavaScript's Date object. Using the ISO datetime format makes it easy to serialize and parse within JSON objects and databases.
We only need to add min & max properties on the ion-datepicker directive to set an upper or lower limit for selection The [pickerOptions] property can take a configuration object to customize the button text and add a custom function handler In the above code, we added a template reference #mydt to set values to the [ (ngModel)]
You should be able to achieve this with setting a attribute minuteValues
to your input like this:
<ion-datetime displayFormat="HH:mm" [(ngModel)]="myDate" minuteValues="0,30">
The minuteValues
can be an array of numbers or a string of comma separated numbers.
EDIT:
Based on comment. ion-datetime
directive is not available in Ionic 1.x but can be used in Ionic 2.x. For Ionic 1.x you can use a plugin like ion-datetime-picker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With