Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (date_time)
Viewing all articles
Browse latest Browse all 4

ACS - Dates with UTC to Local Date

$
0
0

I've been trying to solve this problem for a long long time...

I've come to realize ACS will store all dates sent to the server in UTC format with +0000 instead of my local -0500.

My problem is to convert the Date the Server is sending in UTC string, and convert it to the Phone Local time.

My App on the cloud (ACS) is being manipulated from a Dektop app (AIR app) and fecthed back on Titanium Mobile Apps: 1- The AIR (CMS) app creates Events with a start_time with the -0500 2- The ACS server converts the date to UTC (dates increases by several hours with +0000) 3- The Titanium App now is receiving the UTC date from the server with the UTC Date...

How can I convert the date_time ACS is returning to the Titanium App in it's local time?

I've searched around and many mentioned moment.js, which is fantastic...

so I've done:

Ti.API.info('ACS returned Date: ' + currentEvent.start_time)
var currentTimeWithoutT = (currentEvent.start_time).replace('T',' '); // removed the T
var utcDate = moment.utc(currentTimeWithoutT,'yyyy-mm-dd hh:mm:ss+zzzz');
 
Ti.API.info('utcDate.toString: ' + utcDate.toString())
Ti.API.info('utcDate.toDate: ' + utcDate.toDate())
Above Trace out:
[INFO] ACS returned Date: **2012-11-30T01:30:00+0000**
[INFO] utcDate.toString: **Sat Jan 01 0000 11:30:01 GMT-0500 (EST)**
[INFO] utcDate.toDate: Sat Jan 01 0000 11:30:01 GMT-0500 (EST)

I've tried several options from moment.js ; I removed the T from the original date the server sends cause I couldn't find the T key in the momentJS list, and then kept it, and both instances the dates were just as wrong.

what am I missing?

Please help!


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images