在将当地时间转换为utc时,时间不正确 [英] while converting local time to utc , time is not correct
本文介绍了在将当地时间转换为utc时,时间不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码是
my code is
var convertLocalTimeToUTC = function() {
var date = new Date();
var utc = date.getTime();
var offset = (date.getTimezoneOffset() /60);
var newdate = new Date(utc + (3600000 * offset));
var finaldate = newdate.toLocaleString();
alert(finaldate);
}
此功能无法返回正确的时间如何解决此问题
请有人帮我...
this function does not return correct time how to solve this issue
please some one help me ...
推荐答案
参考
http://stackoverflow.com/questions/948532/how-do-you-convert-a-javascript -date-to-utc [ ^ ]
这篇关于在将当地时间转换为utc时,时间不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文