使用jquery获取格式为UTC 11:30,0的浏览器时区
有人建议我使用格式为“UTC+11:30,0”的浏览器时区吗 使用jquery,因为我只想在数据库中存储“UTC+11:30,0”使用jquery获取格式为UTC 11:30,0的浏览器时区,jquery,Jquery,有人建议我使用格式为“UTC+11:30,0”的浏览器时区吗 使用jquery,因为我只想在数据库中存储“UTC+11:30,0” function calcTime(city, offset) { // create Date object for current location var d = new Date(); // convert to msec // add local time zone offset // get UTC time i
function calcTime(city, offset) {
// create Date object for current location
var d = new Date();
// convert to msec
// add local time zone offset
// get UTC time in msec
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
var nd = new Date(utc + (3600000*offset));
// return time as a string
return "The local time for city"+ city +" is "+ nd.toLocaleString();
}
alert(calcTime('Bombay', '+5.5'));