I have Javascript based app (using Nativescript) in which I'm using moment to do some time manipulation. My server returns dtae times to me in the following string format "9/14/2016 4:52:20 PM" Which are Not in UTC. Depending on where the user is I would like to change the time stamp of this string to match their time zone. So I'm trying to get a string that would look like this "4:52 PM" in EST or "12:52 PM" if it's pacific timezone. I'm currently trying to do this using MomentJS like in the following way:
exports.dateTimeStamp = function(value) {
var utcDate = moment.utc(value);
var localDate = moment(utcDate).local();
var formatedDate = moment(localDate).format('LT');
return formatedDate;
};
Unfortunately this isn't working correctly. As of now If I try to do this and the user is in ****EST (GMT-4:00)**** and the string value I pass in is equal to "9/14/2016 4:52:20 PM" I'm getting back "12:52 PM" Rather than "4:52 PM" Could some one point out what I'm doing wrong? My thought is in involves the switch to UTC but that seems like it's necessary from what I have read.
EDIT I've looked into Moment Timezone, but I don't think that will work since my application is global and it seems Timezone requires a hard coded country/city string to be passed into it. In my case Javascript being used in an Android App. So I get the locale and culture info from the device. Maybe I'm just not quite understanding how to use it.