How can I do this?
EDIT: I'm not sure if this would work but sometimes you get those annoying pop-ups that tell you what city/suburb you're in (usually for dating sites) - could we somehow extrapolate from that data what the time is? Is this data based on a reverse IP lookup?
Any suggestion code to get me started (I don't really know what I'm looking for - just the end result I want) would be fantastic!
Thanks.
Use the Geo Location API to get the user's location, then lookup their local time via some web service like this.
Realise that you have to rely on the time kept on a server somewhere. If your server has the local time to a reasonable degree of accuracy, you could just offset your server's time to match the user's time-zone.
Using JavaScript, dateObject.getTimezoneOffset() can return the offset between the users local time and the GMT in minutes.
First: session_start()
in the php pages
then I would create a small javascript in the bottom of each page that gets the time
if(!isset($_SESSION['browsertime'])) {
?>
document.write('<img src="image.php?time="+browsertime+"&type=.jpg">');
<?php
}
and in the image.php $_SESSION['browsertime']=$_GET['browsertime'];
with some extra checks, of course...
You may want to look at this service EarthTools They provide a service that can return the time of the user on the basis of longitude and latitude.For getting Longitude and latitude you can use another service Smart IP.
Note: Although these services can provide you data but still its not reliable because user may have used proxy servers to access the web so in that way the result will be not valid.