1

How do I check user's timezone using php?
I tried date_default_timezone_get() but it shows "Europe/Berlin" while my actual timezone is "Europe/Warsaw".
Is there any other way to check it using php?
Thanks.

inteNsE-
  • 115
  • 1
  • 4
  • 13
  • 1
    PHP can't get the timezone directly from a web browser for your users, you need to use front-end coding to do this (e.g. javascript) and then send that information to your PHP application – Mark Baker Jan 23 '16 at 17:38
  • 1
    any example please @MarkBaker? – inteNsE- Jan 23 '16 at 17:40
  • you can use geo api or javascript. see: http://snippets.khromov.se/get-visitor-local-time-sunrise-and-sunset-time-by-ip-with-maxmind-geoip-and-php/ – Baron Jan 23 '16 at 17:46

1 Answers1

0

Use date_default_timezone_set ( 'Europe/Warsaw' ) these must be included in all your php files, if you are in MVC pattern in your config or bootstrap file.

If it is possible You can also change your php.ini file : http://php.net/manual/fr/datetime.configuration.php

http://php.net/manual/en/function.date-default-timezone-set.php http://php.net/manual/en/timezones.php

Mouloud
  • 3,715
  • 1
  • 26
  • 20
  • 1
    That doesn't solve my problem. I want to check user's timezone, not server's. – inteNsE- Jan 23 '16 at 17:54
  • oh! i see, but date_default_timezone_get() does not retrieve the user timezone but gets the "default timezone used by all date/time functions in a script" - PHP maybe this can help : http://stackoverflow.com/questions/4746249/get-user-timezone – Mouloud Jan 23 '16 at 17:57