d
is actually a date object. If you pass that to Ti.API.info, or console.log, it'll be coerced in to the string that you see above. You should use its getDate
, getMonth
, and getFullYear
methods to get the string that you want.
var formattedString = (d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear();
Alternatively, use moment.js, which is included in Alloy apps, and can be easily downloaded in to vanilla Titanium apps too:
var moment = require('alloy/moment'),
dm = moment(d),
formattedString = dm().format('L');
This is answered quite simply by a SO answer already:
Where can I find documentation on formatting a date in JavaScript?