Php Class 'DateInterval' not found

user1032317 picture user1032317 · Feb 2, 2014 · Viewed 8.2k times · Source

I am using php version 5.4.24 and I can't use the class DateInterval.
I get this error: PHP Fatal error: Class 'DateInterval' not found

$interval       = new DateInterval('P91D');

What should I do in order to make this code work?

Answer

Kalidass picture Kalidass · Sep 27, 2016

You need to add the following class in the Controllers. Also make sure your php version (PHP 5 >= 5.3.0, PHP 7)

use DateTime;
use DatePeriod;
use DateInterval;

class DashboardController extends Controller
{

}