Timezone processing in PHP and MySQL?

I am testing the login system, but the problem is that the time zone of my host is different from where I live. This is 3 hours on my server, when on my local computer, the time is 4 pm. How do I automatically configure the code that I retrieve from a database displayed as a time zone, similar to where I am?

+3
source share
1 answer

You can set the default time zone using the date_default_timezone_set () function. It sets the default timezone used by all date / time functions in the script.

date_default_timezone_set('America/Los_Angeles');

Take a look at this page:

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

Here you can find a list of time zones.

http://php.net/manual/en/timezones.php

php.ini, . date.timezone :

date.timezone = "US/Central"

date.timezone -:

http://kb.siteground.com/article/How_to_change_the_datetimezone_value_in_PHP.html

+3

Source: https://habr.com/ru/post/1792166/


All Articles