
var win = Titanium.UI.createWindow({
title:"Creating a Date/Time Picker",
backgroundColor:"#FFFFFF",
exitOnClose:true
});
//We'll use Javascript's Date object within the date picker
var minDate = new Date();
minDate.setFullYear(2011);
minDate.setMonth(01);//0 = January; 11 = December
minDate.setDate(01);
var maxDate = new Date();
maxDate.setFullYear(2020);
maxDate.setMonth(10);
maxDate.setDate(31);
var setValue = new Date();
setValue.setFullYear(2011);
setValue.setMonth(10);
setValue.setDate(01);
var results = Titanium.UI.createLabel({
text:"The date will appear here",
top:24,
width:"auto",
height:"25%",
textAlign:"center",
color:"#000000"
});
var picker = Titanium.UI.createPicker({
selectionIndicator:true,
minDate:minDate,
maxDate:maxDate,
value:setValue,
type:Titanium.UI.PICKER_TYPE_DATE
/*
Titanium.UI.Picker constant tyes are:
Titanium.UI.PICKER_TYPE_COUNT_DOWN_TIMER
Titanium.UI.PICKER_TYPE_DATE
Titanium.UI.PICKER_TYPE_DATE_AND_TIME
Titanium.UI.PICKER_TYPE_PLAIN
Titanium.UI.PICKER_TYPE_TIME
*/
})
picker.addEventListener("change", function(e){
//for date/time pickers, you can use e.value to return a UTC formatted Date object
//You can then parse from here
results.text = e.value;
});
win.add(picker);
win.add(results);
win.open();