This document will demonstrate you to get the time of a location using Google Time API in java script.Simply we need the Latitude and Longitude of location to do that.Hope following code lines will help you.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
//Sending A Default Location
var Latitude = 6.0535185;
var Longitude = 80.22097729999996;
getTimeUsingLatLng(Latitude,Longitude);
function getTimeUsingLatLng(lat,lng){
var times_Stamp = (Math.round((new Date().getTime())/1000)).toString();
$.ajax({
url:"https://maps.googleapis.com/maps/api/timezone/json?location=" + lat + "," + lng + "×tamp=" + times_Stamp,
cache: false,
type: "POST",
async: false,
}).done(function(response){
if(response.timeZoneId != null){
var Cur_Date = new Date();
var UTC = Cur_Date.getTime() + (Cur_Date.getTimezoneOffset() * 60000);
var Loc_Date = new Date(UTC + (1000*response.rawOffset) + (1000*response.dstOffset));
$("#timeOfLocation").html("Time Of The Location Is " + Loc_Date.toLocaleString());
}
});
}
});
</script>
</head>
<body>
<p id = "timeOfLocation"></p>
</body>
</html>
Subscribe to:
Post Comments (Atom)
JWT Token Decode Using Jquery
When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...
-
In this blog post Ill explain you the logic behind the Sri Lankan National Identity Card (NIC). Sri Lanka now has Old NIC No Format as well ...
-
In This Article I Will Demonstrate You To Create A Simple Chat Program Using Java Remote Method Invocation(RMI). Following Program Supports ...
-
In a windows form application sometimes you may want to import a excel file to a data grid view. In this blog post Ill demonstrate to you gu...
No comments:
Post a Comment