“Class Datetime Not Found” Error in Joomla

Yesterday (yes – we work on Sundays!), we were moving a Joomla website hosted on a Plesk version 9 server to a Plesk version 11 server – the transfer was pretty smooth, except that when we tested the website on the new server, we got a blank page. Restarting Apache didn’t solve the problem (although it did, on other occasions), and modifying the configuration.php file to change error reporting to maximum still yielded a blank page.

So, we started to debugging Joomla, and, after a while, we were successful in forcing Joomla to spit the actual error. It was this one:

Class ‘DateTime’ not found in /libraries/joomla/utilities/date.php on line 20

Huh?

We know that DateTime is a core PHP class, so how come Joomla can’t find it. So, we checked the documentation of the DateTime class on the php.net website, and it turned out that this function requires a PHP version of at least 5.2. To our surprise, the new server that we were moving to had a PHP version of 5.1.5. We were shocked!

Unfortunately, Plesk only allowed us to upgrade to PHP version 5.3.5 – which was enough to solve the problem, but far from ideal, since the current PHP version (at the time of writing this post) is PHP 5.5.4.

So, if you’re having a blank page issue when moving your Joomla 2.5 website from one server to another, you should do the following:

  • Restart Apache on the target (new) server (it might be that the directory structure is cached).
  • Ensure that you have the minimum PHP version (which is 5.2.4) and MySQL version (which is 5.0.4) required to run Joomla. You can do this check by creating and running a small PHP file that has the following single line code:

    <?php phpinfo(); ?>

    Running the above file will give you all sorts of information about your LAMP environment, including the PHP, MySQL, and Apache version. If you find the information generated by that file overwhelming, then you can replace its content with the below:

    <?php
    	echo("Apache Version Is: ".apache_get_version()."<br />");
    	echo("MySQL Version Is: ".mysqli_get_client_version()."<br />");
    	echo("PHP Version Is: ".phpversion()."<br />");
    ?>

    The above will just return the Apache version, the MySQL version, and the PHP version you have on your server.

Now, if you have done all the above and you’re still getting the same problem (or if you don’t have the technical skills to do what’s written in this post), then fear not. All that you need to do is to contact us! We are always there, we are immediately available, we can solve your problem in no time, and we won’t charge you much!

No comments yet.

Leave a comment