如何使用 angularjs 控制器将 UTC 时间转换为不同的时区?

How to convert UTC time into different time zone using angualrjs controller?

我收到来自 api 的时间 (hh:mm) 响应,它是 UTC 时间 formate.As 每个印度标准时间 (+5.30) 我需要转换 time.With在控制器中,我有转换这些 things.can 有人帮我吗?

你可以使用 moment.js , 假设你在变量 say 'utctimedata' 中收到你的请求 你可以用片刻。 js函数。

var istCovertedData = utctimedata.local().format('YYYY-MMM-DD h:mm A');

如果需要,您可以在控制台中进行相同的测试

var getcurrentdate=moment.utc("2017-01-13 20:00", "YYYY-MM-DD HH")

var localGetcurrentdate = getcurrentdate.local().format('YYYY-MMM-DD h:mm A'); 希望我足够清楚