0

Hi I have a task where in I need to capture user access details like the browser, OS version and the timezone it is using.

However I am able to work around for the solution of detecting browser and OS version.

I am looking for a solution where my php code can detect what was the Timezone user is having when he tried to access my web page. Also how do I convert that time of user to the server time.

Thanks in advance.

chandresh_cool
  • 11,753
  • 3
  • 30
  • 45
  • Looking for a javascript solution? PHP runs on the server and javascript runs on the client. – Antony Apr 05 '13 at 13:11

1 Answers1

2
-new Date().getTimezoneOffset()/60;

getTimezoneOffset() will subtract your time from GMT and return the number of minutes. So if you live in GMT-8, it will return 480. To put this into hours, divide by 60. Also, notice that the sign is the opposite of what you need -- it's calculating GMT's offset from your time zone, not your time zone's offset from GMT. To fix this, simply multiply by -1

웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91