How to convert UTC date to Javascript?

I am getting a date from a web service that has a format date "2013-02-06T10:40:56.027"

like how to convert it to "2/6/2013 2:40 AM"

.

enter image description here

Web Service I am getting from SocialDataService Sharepoint 2010

I am trying moment javascript:

var date = moment(lastModifiedTime);

var result = date.format("MM/DD/YYYY hh:mm A");

      

but the result is not the correct hour: 02/06/2013 10:40 AM

I expected the result: 02/06/2013 2:40 AM

+3


source to share


2 answers


if you can assume your service is returning UTC time, you can try something like:

moment.utc(result_from_service).local()

      



for more details: http://momentjs.com/docs/#/manipulating/utc/

+3


source


//Manually add time zone to the date string
var date = moment(lastModifiedTime + "+15:00");
var result = date.format("MM/DD/YYYY hh:mm A");

      



0


source







All Articles