The real, full contents of the file:
<?php
error_reporting(E_ALL);
ini_set(display_errors, 'on');
try {
//$x = strtotime('blah');
$x = new DateTime('lol');
} catch ( Exception $e ) {
echo $e->getMessage();
}
The DateTime constructor accepts a string, which should throw an exception if it can't parse it. This runs fine on my local machine but on one of my remote servers the exception is not caught ( and again, I am using try/catch and the SAME EXACT code ):
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [function.DateTime---construct]: Failed to parse time string (lol) at position 0 (l): The timezone could not be found in the database' in /var/www/html/site_com/rez/date.php:9 Stack trace: #0 /var/www/html/site_com/rez/date.php(9): DateTime->__construct('lol') #1 {main} thrown in /var/www/html/site_com/rez/date.php on line 9
Settings for remote server where the exception is not caught:
PHP Version 5.2.5
date date/time support enabled "Olson" Timezone Database Version 2007.9 Timezone Database internal Default timezone America/Chicago
Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value
My local settings where it does work:
PHP 5.2.10
date date/time support enabled "Olson" Timezone Database Version 0.system Timezone Database internal Default timezone System/Localtime
Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value
Locally, it catches the exception and prints the error out. The date.timezone
on both is no value.
Perhaps it's just my internal system's timezones which are off? My local box is Ubuntu and my remote is CentOS, they're probably inconsistent but shouldn't PHP still catch the exception?
FYI I can't update PHP on the remote box since I don't have admin rights.