php - How to get the user's system clock time to display in a web application?


I noticed when I accessed my gmail account after I changed my system clock on windows 7 from Pacific to Eastern time, the timestamp in all my emails went up by 3 hours.

Is there a way I can obtain a user's system clock time so I can display it in a web application?

I mainly use php for writing web apps but I did not see and$_SESSION variables that contain that information.




PHP doesn't run on the client but on the server, so if you want to do this you can use some JavaScript.

function set_time() {

var d = new Date();
var c_hour = d.getHours();
var c_min = d.getMinutes();
var c_sec = d.getSeconds();
var t = c_hour + ":" + c_min + ":" + c_sec;
return t;


People are also looking for solutions to the problem: Php PDO Mysql error 1064 inserting


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.