时区api INVALID_REQUEST

时间:2016-01-15 23:25:33

标签: javascript jquery google-maps-api-3

我似乎无法找到造成这种情况的原因。我一次又一次检查了网址,我似乎无法找到它的错误。

function setTime() {
min = $("#minutes").val();
hour = $("select").val();
odG = $("#odGodina").val();
doG = $("#doGodina").val();
dat = $("#datepicker").val();
dat = dat.split("/"); //mm.dd.YYYY
vreme = new Date(dat[2], dat[0], dat[1], hour, min);
sendInput(vreme);
}
function sendInput(time) {
console.log(time.getTime());
var url = "https://maps.googleapis.com/maps/api/timezone/json?location="+lat+","+lngt+"&timestamp="+time.getTime()+"&sensor=false";
var testResenje = $.ajax({ 
    url: url, 
    }).done(function(response) {
        offset = response.rawOffset / 3600 + response.dstOffset / 3600;
        sendResponse();
        console.log(offset);
    });}

构建的网址是:

https://maps.googleapis.com/maps/api/timezone/json?location=44.7220401,21.175114500000063&timestamp=1455189900000&sensor=false

long和lat有多少个字符有问题?

或者我的功能订单不好?

编辑:如果我的时间戳中有一个字符少,那就可以了。这是否意味着我无法使用当前时间?

1 个答案:

答案 0 :(得分:1)

Google timezoneapi希望将时间戳作为unix时间戳代表毫秒数的秒数。

  

timestamp指定自UTC时间1970年1月1日午夜起所需的时间。

参考:https://developers.google.com/maps/documentation/timezone/intro