Welcome Guest, Not a member yet? Register   Sign In
DateTime php function causing error

(This post was last modified: 05-24-2020, 11:27 AM by kick.)

I am trying to get the difference between two dates and wanted to use the basic date->diff function of the DateTime class in php, however the error I am receiving from CodeIgniter 4.0.3 is that it can't find the DateTime class in my controllers directory. Here is what I am doing:

PHP Code:
$date1 = new DateTime($dobStr);
$date2 $date1->diff(new DateTime(date('m/d/Y',time())));


Has anyone gotten this error if so what have you done to get around it? Thanks in advance.

I found a way around it by turning it into a helper method.

I would still appreciate it if anyone know how/why declaring a new PHP native class would cause CI4 to look for it within it's calling class directory and if there is other ways of accomplishing the calls to native classes.

Messages In This Thread
DateTime php function causing error - by kick - 05-24-2020, 11:10 AM

Theme © iAndrew 2016 - Forum software by © MyBB