I want to display the dates from an fb event in a nice manner.
I am getting the event string from fb and then i make this:
var eventDate = eventToDisplay.start_date; var temp = eventDate.split("T"); eventDate = temp[0].split("-"); eventDate = eventDate[1] + "/" + eventDate[2] + " " + eventDate[0]; var eventTime = temp[1].split("+"); var dateStringStart = " " + eventDate + " " + eventTime[0]; var start = moment(dateStringStart).format('LLL'); var eventstart = Ti.UI.createLabel({ font:{ fontSize : 16, fontWeight : 'bold' }, color : '#eee', left : "40dp", top : "35dp", height : 'auto', width : 'auto', text : start }); Win.add(eventstart);By running it thru moment.js i get the date to display as:
November 9 2012 8:00 PM
And that is good!
But i want to loose the 2012
So if i try to remove the
eventDate[0]it displays as:
November 9 00-1 8:00 PM
So how do i loose the 00-1?
I only want it to display as:
November 9 8:00 PM
Thanx.
2 Answers
Accepted Answer
It looks to me like he's already using moment.js.
Richard: it's better to specify the complete date to moment, and then format the output string the way you want, rather than manipulating what you feed into moment. You want the date object created by moment to be a legitimate date object.
What if you did this:
var start = moment(dateStringStart).format('MMMM D, h:mm a');Consult the moment.js docs for complete formatting options.
The mother of all date formatting and manipulation: momentjs
http://momentjs.com/
Your Answer
Think you can help? Login to answer this question!