I’m working with the date and time in my Titanium based iOS application.
My issue is, I’m getting the time in the below format:
Wed Jan 16 2013 17:32:40 GMT+0530 (IST)
I want to change it like:
Jan 16, 2013, 05:32 pm
In iOS there is NSDateFormatter for doing this.
What I did :
- Currently I’m doing it manually using
splitand switchcases, but it fails if the input time format changes, then I need to re-write the code for the changed format. - I searched alot in Titanium Docs, but didn’t get any solution.
- I asked same question on their forum, didn’t get any reply till now.
Is there is anyway to do this in Titanium?
Please help, Thanks in advance.
I didn’t find any alternatives for the
NSDateFormatterin Titanium.I tested the Moment.js, but it didn’t worked for my case.
I implemented a JavaScript function for achieving my output.
Edit on 27 Feb 2014
After facing the JavaScript date formatting issue on different occasions, I finally developed my own JavaScript module, this module will format the JavaScript Date object to Specified formats. You can find it here : MMP_DateTime