Fix different date between PHP and CentOS server

Odd thing happen today when I see big difference between date from PHP output and date from shell.

PHP output :

22-12-2015 06:15:43

Shell output :

# date
Sel Des 22 13:19:54 WIB 2015

7 hour difference.

A few checklist for this case :

  1. Copy right timezone to localtime

# cp /usr/share/zoneinfo/Asia/Jakarta /etc/localtime

2.  Add right timezone to php.ini

#nano /usr/local/lib/php.ini

date.timezone = “Asia/Jakarta”

3. Check sysconfig clock

# nano /etc/sysconfig/clock

change Zone to “Asia/Jakarta”

4. Check for hardware clock aka hwclock

# hwclock
Sel 22 Des 2015 06:34:40 WIB -0.707297 seconds

Done.