Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert UTC Date by Javascript?

I get date from Web Service have format date like "2013-02-06T10:40:56.027" how to convert it to "2/6/2013 2:40 AM".

enter image description here

Web Service I get from SocialDataService of Sharepoint 2010

I try moment javascript:

var date = moment(lastModifiedTime);

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

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

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

like image 404
Garu Jwon Avatar asked Apr 11 '26 04:04

Garu Jwon


1 Answers

if you can assume your service returns UTC time, you could try something like:

moment.utc(result_from_service).local()

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

like image 75
Pascal Belloncle Avatar answered Apr 13 '26 21:04

Pascal Belloncle