Issue:

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.

Fix :

For checking the php time, put the following code in a file, say time.php

<?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.

[root@localhost ~]# 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 :

[root@localhost ~]# 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.

[root@localhost ~]# 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.


Shares
Contact Us On WhatsApp