HTML DOM Geolocation timestamp Property
In this article, we will discuss the Geolocation timestamp property. Geolocation in HTML is used to get the geographical position of a user. The getCurrentPosition() method, in this geolocation, returns an object on success.
Syntax:
timestamp
Return Value:- This geolocation property returns an object on success.
Example: The following HTML code returns the timestamp.
HTML
<!DOCTYPE html> < html > < body > < h2 style = "color:green" > GeeksforGeeks </ h2 > < p > < b >Displaying Timestamp</ b > </ p > < button onclick = "getlocation()" > Click Me </ button > < p id = "paraID" ></ p > < script > var variable1 = document.getElementById("paraID"); function getlocation() { navigator.geolocation .getCurrentPosition(showLoc); } function showLoc(pos) { variable1.innerHTML = "Timestamp: " + pos.timestamp; } </ script > </ body > </ html > |
Output:
Supported Browsers:
- Google Chrome 5 and above
- Edge 12 and above
- Firefox 3.5 and above
- Internet Explorer 9 and above
- Opera 16 and above
- Safari 5 and above
Please Login to comment...