I would like to get the current time in Javascript/ Jquery.
I could just use Math.floor($.now() / 1000)
but that will return the time from the browser which could be accurate but possibly in the wrong timezone. I have setup the file time.php on my server which when visited returns the current unix timestamp for the correct timezone. Now all I need to do is get this into Javascript. I thought about using a jquery function like this:
function time(){
$.ajax({url: "time.php", success: function(result){
return(result);
}});
}
alert(time());
but that doesn't seem to work as the function comes back as undefined. Is there a solution to this that enables me to call alert(time());
?