typescript - How to change TimePicker in NativeScript to show the time in 24-hour format? -
in nativescript, there timepicker, 1 shows time, in 12-hour format. have problem, because in database of times saved in string (in format "23:59").
i canot set hour, e.g. 14.
i have idea, convert string split(':')
, changing period pm, cannot see usefull method that. please, help.
you can use native apis set 24-hour format. timepicker in nativescript using uidatepicker in ios , android.widget.timepicker in android
page.js
"use strict"; var application = require("application"); function onloaded(args) { var page = args.object; var tpicker = page.getviewbyid("tpicker"); if (application.android) { tpicker.android.setis24hourview(java.lang.boolean.true); tpicker.hour = 23; tpicker.minute = 59; } else if (application.ios) { // bit hacky solution // important set country not language locale var local = nslocale.alloc().initwithlocaleidentifier("nl"); tpicker.ios.locale = local; tpicker.hour = 23; tpicker.minute = 59; } } exports.onloaded = onloaded;
page.xml
<timepicker id="tpicker"></timepicker>
Comments
Post a Comment