-1

I was wondering whether to use APIs or Javascript to get the timezone of client system or simple store timezone of logged in user in database. Could you please suggest me which is better and feasible?

Context: employees will be logging in to site from different countries. So their requests will have to be solved in a time bound manner. Here datetime calculation is required.

Thanks!

Ravistm
  • 2,163
  • 25
  • 25

2 Answers2

1

You can send it to the server together with the client login. Simply add a hidden input in which to write the zone/time with javascript. And then store it in session or database.

Do it on each login because the client may switch zones.

This solution is better for me - more simple and straight forward.

If you prefer ajax javascript solution check this question: how-to-get-clients-timezone

Community
  • 1
  • 1
0

PHP only display server side time.

For client side time you need to use javascript.

JS Code:

var dt = new Date();
var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
Hiren Makwana
  • 1,976
  • 2
  • 13
  • 28