Reputation: 1024
Is there any server or client side way to determine their location and get the local time.
I'd like it to also update in real time, e.g. hour, mins, secs.
I'd prefer it if I can use PHP / JavaScript (jQuery included) or something like that.
Upvotes: 2
Views: 2104
Reputation: 146219
You may want this
setInterval(function(){
var dt=new Date(), h=dt.getHours(), m=dt.getMinutes(), s=dt.getSeconds(),
curTime= pad(h)+':'+pad(m)+':'+pad(s);
document.getElementById('time').innerHTML=curTime;
}, 500);
function pad(n) { return ("0" + n).slice(-2); }
DEMO.
Upvotes: 2
Reputation: 6711
In JavaScript you can easily get the current date and time using the Date object;
var now = new Date();
This will get the local client machine time.
Upvotes: 0
Reputation: 1373
You can try using jquery localtime plugin. Take a look [here]: http://code.google.com/p/jquery-localtime/wiki/Usage
Upvotes: 1