Uncaught Error: Class 'DateTime' not found

I re-downloaded the installer again, uninstall the older, install the downloaded version, then after re-generating ALL the script files, I got the following error:

Fatal error: Uncaught Error: Class ‘PHPMaker2020\demo2020\DateTime’ not found in D:\wamp\www\demo2020_original\phpfn.php on line 326.

Here is the complete code around line 326 of the file:

function CreateConsentCookie() {
$date = new DateTime(); // <— here is line of 326
$date->setTimestamp(Config(“COOKIE_EXPIRY_TIME”));
return PROJECT_NAME . “[” . Config(“CONSENT_COOKIE_NAME”) . “]=1;path=/;expires=” . $date->format(DateTime::COOKIE);
}

Click Tools → Update Template to update to latest one.

After updating to the latest template, now it works properly. Thank you.

My ListOptions_Rendered server event:

function ListOptions_Rendered() {
$year_mm=substr($this->weekyear->CurrentValue,0,4);
$week_mm=substr($this->weekyear->CurrentValue,5,2);
$week_start = new DateTime();
$week_start->setISODate($year_mm,$week_mm);
$this->ListOptions->Items[“WeekStart”]->Body =
$week_start->format(‘d-M-Y’);

}

Fatal error: Uncaught Error: Class “PHPMaker2020\hours\DateTime” not found in C:\xampp\htdocs\hrs\classes\hours_emp_week_new_list.php:2006 Stack trace: #0

If you use DateTime in your own code, make sure you use \DateTime, e.g. $date = new \DateTime();. See Using namespaces: Basics.

Change this code:

$week_start = new DateTime();

to:

$week_start = new \DateTime();

tks work now