Trim string, e.g. for date picker
Hello together!
I have a problem to trim my string i get from the date picker.
I recive this string:
Fri May 28 2010 16:46:41 GMT+0200 (CEST)
(Ok… strange, few minutes ago i got the date as 2010-05-28 ?!)
So, anyone know how to get the old date back?
But back to my old question:
I want to trim the (old) string:
2010-05-28 16:46:41 GMT+0200
to
2010-05-28
i tried it with:
datePicker.addEventListener('change', function(e){
searchDate = e.value; // here i get an output with Ti.API.Info
searchDate = searchDate.substring(0,9); // here i get nothing when i try t get an output with Ti.API.info
i tried substr, substring non of these are working.
Any suggestions?
1 Answer
-
Accepted Answer
Try something like this…
picker.addEventListener('change',function(e){ var pickerdate = e.value; var day = pickerdate.getDate(); var month = pickerdate.getMonth(); var year = pickerdate.getFullYear(); var newdate = year + "-" + month + "-" + day; });