CurrentDateTime() is not working

PHPMaker v2026.5

I use the below syntax in Row_Inserting:

$newRow['CREATED_AT'] = CurrentDateTime();

Seems like it’s not working anymore as I’m getting the below error when I add record:

TypeError:
PHPMaker2026\MyProject\Db\Entity\Userlevel::setCreatedAt(): Argument #1 ($value) must be of type ?DateTimeInterface, string given, called in E:\www\MyProject\src\Entity.php on line 189

  at E:\www\MyProject\src\Db\Entity\Userlevel.php:121
  at PHPMaker2026\MyProject\Db\Entity\Userlevel->setCreatedAt('2026-01-23 04:15:50')

Now I have to change the code to the following:
$newRow['CREATED_AT'] = new \DateTime(CurrentDateTime());

May I know if this is intended or otherwise?

You're right. Don't use the old CurrentDateTime() anymore, it returns string, not suitable for entities used by v2026.

However, there is no need to use new DateTime(CurrentDateTime()), you may simply use new DateTime().

1 Like

However, if you want to auto-fill the value of current datetime with the string value in Add Page, for example, then you may simply use the following code in Row_Rendered server event for such case above:

if (CurrentPageID() == “add”) {
$this->CREATED_AT->EditValue = CurrentDateTime();
}