Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP command line error : Timezone database is corrupt

My date.php is -

<?php
echo date('Y');

When I execute php -f date.php on my staging machine, I get error -

PHP Fatal error:  date(): Timezone database is corrupt - this should *never* happen! 
in /home/staging/test/date.php on line 2

But when I execute the same on my local / dev machine it works. Although on both staging and local machines, permissions on /etc/localtime and /usr/share/zoneinfo/ are the same.

But output of file /etc/localtime vary on both machines.

Local (php5.3.5) :

/etc/localtime: timezone data, version 2, 4 gmt time flags, 4 std time flags, no leap seconds, 4 transition times, 4 abbreviation chars

Staging (php5.3.10) :

/etc/localtime: timezone data, version 2, 1 gmt time flag, 1 std time flag, no leap seconds, no transition times, 1 abbreviation char

While trying to find what the issue is I found this link from SO. I am confused over the accepted answer. My apache user is not executing the script.

What seems to be the problem? How do I resolve this issue?

like image 626
Hussain Avatar asked Dec 23 '13 12:12

Hussain


1 Answers

For various reasons, PHP ships with its own timezone database - it is possible to use the system TZDB by configuring the software differently at compile time.

The PHP timezonedb is implemented as C code (lots of defines) - hence you need to recompile PHP to get it working.

If your PHP interpreter is not explicitly configured to use the OS timezoneDB, then you really need to investigate why the executable is corrupt.

like image 77
symcbean Avatar answered Oct 14 '22 22:10

symcbean