标签:select date ted emd start split utc zone 获取
// 根据时间戳转本地时区时间
function getLocalTime(cityZoneNum, d) {
var len = d.getTime();
var offset = d.getTimezoneOffset() * 60000;
var utcTime = len + offset;
var dZone = new Date(utcTime + 3600000 * cityZoneNum);
var vYear = dZone.getFullYear();
var vMon = dZone.getMonth() + 1;
var vDay = dZone.getDate();
var h = dZone.getHours();
var m = dZone.getMinutes();
var se = dZone.getSeconds();
if(h < 10) {
h = ‘0‘ + h;
}
if(m < 10) {
m = ‘0‘ + m;
}
// console.log(vYear + "年" + vMon + "月" + vDay + "日" + h + ":" + m, 222);2012-10-12 22:37:33
return vYear + "-" + vMon + "-" + vDay + " " + h + ":" + m;
}
//计算在当前国家当地时间戳
function parseGTM(gmt, d) {
gmt = gmt.replace("GMT", "");
var t = gmt.split(":")
if("+" == t[0][0]) {
t[0] = t[0].replace("+", "");
}
var ts;
if("30" == t[1]) {
ts = t[0] + ".5";
} else {
ts = t[0];
}
return getLocalTime(ts, d);
}
var startTimeMdd;
function start_time_jisuan() {
var gmt= $("#country_code option:selected").val(); //获取目的国的gmt,由后端传过来
var start_time = $("#startTime").val(); //获取当前选择的日期,开始日期
var timestamp = Date.parse(new Date(start_time));//开始日期转时间戳
var startTimeMdds = parseGTM(gmt, new Date(timestamp)); //将当前日期时间戳转目的国日期
console.log(startTimeMdds,6666)
startTimeMdd= Date.parse(new Date(startTimeMdds)); //将目的国日期日期格式转为时间戳
return startTimeMdd;
}
标签:select date ted emd start split utc zone 获取
原文地址:https://www.cnblogs.com/Fancy1486450630/p/10419117.html