Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to determine the users time from a web request?

Is it possible on a web server to determine the users local time and timezone when they sent the request?

Could it be done using javascript to capture it and post it back to the server?

My company want to track how many users use our site outside of office hours (no I dont really know why either!).

Thanks.

like image 604
Simon Keep Avatar asked Dec 17 '22 09:12

Simon Keep


2 Answers

You need to put the client's JavaScript time into a hidden field, and assume their clock is set properly.

myTime = new Date() >> Tue Feb 03 2009 12:24:28 GMT-0500 (Eastern Standard Time)
like image 194
Diodeus - James MacFarlane Avatar answered Jan 04 '23 22:01

Diodeus - James MacFarlane


You could load a date into a hidden field using JavaScript:

var newDate = new Date();
hiddenFieldName.value = newDate.toLocaleString();

Then on the postback to the sever grab that field.

like image 30
Miyagi Coder Avatar answered Jan 04 '23 23:01

Miyagi Coder