Php function was returning wrong time. There was a difference of 1 hour between the server time and the php time. Due to this ,most of the functions on the site were not working properly.
For checking the php time, put the following code in a file, say time.php
$time = time();
$result = date(“Y-m-d (D) H:i:s”,$time);
echo “Current date and local time on server = $result “;
Execute the php script.
[[email protected] ~]# php -a time.php
Interactive mode enabled
Current date and local time on server = 2017-01-30 (Mon) 18:04:25
To get the server time , issue the following command :
[[email protected] ~]# date
Mon Jan 30 17:04:25 IST 2017
You can see the difference of one hour between the server time and the php time.
For fixing this, you need to install the PECL timezonedb module.
[[email protected] ~]# pecl install timezonedb
At the end , you might see the following message :
Build process completed successfully
Installing ‘/usr/local/lib/php/extensions/no-debug-non-zts-20060613/timezonedb.s o’
install ok: channel://pecl.php.net/timezonedb-2009.6
configuration option “php_ini” is not set to php.ini location
You should add “extension=timezonedb.so” to php.ini
So , add the line ” extension=timezonedb.so” to the php.ini file and restart apache.
There shouldn’t be any mismatch in time now.