Hussain
Hussain

Reputation: 5187

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?

Upvotes: 6

Views: 4280

Answers (3)

sffc
sffc

Reputation: 6424

My problem was that I was running php-fpm in chroot mode. I changed it to run without a chroot, and then the error went away.

Upvotes: 0

user3283364
user3283364

Reputation: 1

Please check permission of your timezone files.It might have changed when you have  install some rpms. 
change the permission to 655
Also check following files:

/usr
/lib
/share
/etc

Upvotes: 0

symcbean
symcbean

Reputation: 48367

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.

Upvotes: 1

Related Questions