Reputation: 256
I can't seem to find what is causing this. I checked the url again and again and I can't seem to find what is wrong with it.
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+"×tamp="+time.getTime()+"&sensor=false";
var testResenje = $.ajax({
url: url,
}).done(function(response) {
offset = response.rawOffset / 3600 + response.dstOffset / 3600;
sendResponse();
console.log(offset);
});}
The url that gets build is:
Is there a problem with the number of characters long and lat have?
Or is my function order bad?
EDIT: Turns out if i have one less character in timestamp it works. Does that mean I can't use current time?
Upvotes: 2
Views: 1635
Reputation: 61
Google timezoneapi expects timestamp as seconds as how unix timestamp represents not milliseconds.
timestamp specifies the desired time as seconds since midnight, January 1, 1970 UTC.
ref: https://developers.google.com/maps/documentation/timezone/intro.
Upvotes: 6