UTC到GMT转换为Javascript

时间:2014-10-04 10:56:39

标签: javascript datetime gmt

我需要在请求的时区将UTC /本地时间转换为GMT +(?)格式... 例如..

UTC to GMT 0
UTC to GMT+1
UTC to GMT-1
UTC to GMT+5
UTC to GMT-5
GMT+5 to GMT+4
GMT+5 to GMT-3

2 个答案:

答案 0 :(得分:2)

var inputDateTime = "Thu Sep 24 2015 15:00:00 GMT+0530 (IST)";
var date = new Date(inputDateTime );
var GMTtime= ((date.getUTCMonth() + 1 ) + '/' + date.getUTCDate() + '/' + date.getUTCFullYear()+ ' ' + date.getUTCHours()+ ':' + date.getUTCMinutes()+ ':' + date.getUTCSeconds()+" GMT");

答案 1 :(得分:0)

UTC是GMT,用于最切实可行的目的。我们(英国人)发明了它。只需添加/减去小时数。

请访问格林威治。就在伦敦郊外。