Fatal Error Local Time()

hi

i am getting the below error


Fatal error: localtime() [<a href='function.localtime'>function.localtime</a>]: Timezone database is corrupt - this should *never* happen! on line 117

This is how i am getting time



116 : $now = time();
117: localtime(time(),true);
118: getdate();
119 : $dated = date('Y-m-d');


Is it a server error or i m doing something wrong ?

Thanks
Vineet

Looks like the PHP date_default_timezone_set() has not been set.
[B]

Errors/Exceptions[/B]

Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using the system settings or theTZ environment variable. See also date_default_timezone_set()

Hi John

date_default_timezone should be set in PHP script and On Server Both ??

I tried to set in php script but getting the same error.

I think it need to be set on my hosting server also.

Vineet

Hi,

I have not been able to duplicate your problem but many others have :slight_smile:

Google “Timezone database is corrupt - this should never happen!”

I believe that PHP version 5.3 made changes to the date() and unless the timezone was set a Notification Warning was generated. To get round this it was possible to either set the timezone or to set the error_reporting() to a lower value.

Timezone can be set in your php.ini file but does require an Apache Server reset. Easiest solution is to set the following:


[COLOR=#545454][FONT=arial]
echo '<br />' .date_default_timezone_get(); 
[/FONT][/COLOR][COLOR=#545454][FONT=arial]
echo '<br />' .[/FONT][/COLOR][COLOR=#545454][FONT=arial]date_default_timezone_set( 'Asia/Bangkok' ); // replace '[/FONT][/COLOR][COLOR=#545454][FONT=arial]Asia/Bangkok[/FONT][/COLOR][COLOR=#545454][FONT=arial]' with your timezone abbreviation
[/FONT][/COLOR]
[COLOR=#545454][FONT=arial]echo '<br />' .[/FONT][/COLOR][COLOR=#545454][FONT=arial]date_default_timezone_get(); [/FONT][/COLOR]

// no errors, notifications or warnings
error_reporting(0); 

$now = time();  
localtime(time(),true);  
getdate();  
$dated = date('Y-m-d');      

 // maximum error reporting()
error_reporting(-1);

$now = time();  
localtime(time(),true);  
getdate();  
$dated = date('Y-m-d');