Trang chủ > Hướng dẫn sử dụng Cloud VPS > Web server > How to setup timezone for php in CentOS

How to setup timezone for php in CentOS

Setup the default timezone is very necessary for proper data processing send from various countries. This article will help you to know how can we setup a default timezone in PHP configuration file (php.ini) or inside any php script for temporary use.

The fist, you can check timezone for your system by php info:

For change, you can as follows.

Step 1 - Choose correct timezone, what timezone you need to configure in your php.ini file. Use below link to find available timezones for php

Step 2 - Login system by root via ssh and edit file php.ini.

Step 3 - Find "date.timezone" on file php.ini (line 877), for example you want to configure ‘Asian/Ho_Chi_Minh’ as your default timezone.

Step 4 - Save configure and restart service apche (httpd) or php-fpm

[root@unica ~]# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]

Step 5 - Check try again.


Success !

Copyright © 2005 iNET - Nhà đăng ký Tên miền Việt Nam và Quốc tế