Note that there are some explanatory texts on larger screens.

plurals
  1. POTitanium - How to display Month-Date-Year Only
    text
    copied!<p>I'm trying to create a label that allows user to select a date in Titanium. My code compiles, but it displays both the date and time when I ask for date only (note: I do my testing with an Android emulator). Can someone take a look at my code and give me a hint on how to solve this issue? Your help is greatly appreciated!</p> <pre><code>//create a new window var addWin = Titanium.UI.createWindow({ title: "Add New Entry", backgroundColor: '#ffffff' }); //header //addWin.add(Inova.ui.createHeaderView()); //error //body var body = Titanium.UI.createView({ backgroundColor:'#fff', height: 800, layout: 'vertical' }); //Addin a label to the body body.add(Titanium.UI.createLabel({ text: 'New Travel Entry', top: 10, color: '#008000', textAlign: 'center', font: {fontSize:20}, width:'auto', //Define width of the label height:'auto' //Define height of the label })); var dateLabel = Titanium.UI.createTextField({ text: 'Date: ', hintText:'Click here to select a date', font: {fontSize: 20}, top:20, left:10, width:'auto', height: 'auto', color: '#336699', editable:false, borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED }); var dateUpdated = false; dateLabel.addEventListener('click', function(e){ var picker = Titanium.UI.createPicker({ type: Titanium.UI.PICKER_TYPE_DATE, minDate: new Date(2012,1,1), maxDate: new Date(2014,12,30), value: new Date(2013,12,2) }); picker.showDatePickerDialog({ value: new Date(2012,12,2), callback: function(e) { if (e.cancel) { Titanium.API.info('User canceled dialog'); } else { Titanium.API.info ('USer selected date: ' + e.value); dateLabel.value = e.value; dateLabel.text = (e.value.getMonth() + 1) + '/' + e.value.getDate() + '/' + e.value.getFullYear(), dateUpdated = true; } } }); }); body.add(dateLabel); addWin.add(body); addWin.open(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload