Entering a default DateTime field

(v2026)

All my old ways from previous versions don’t seem to work any more. All I want to do is put the current Date/Time into a DATETIME d/b field when adding a record.

  • I can’t find anything that works using the usual Add Page ‘Default Value’ setting. Tried
    new \DateTimeImmutable()
    … but that just put a NULL in the d/b entry
  • Tried setting d/b field default to CURRENT_TIMESTAMP but for some reason the PHPM app always sets the field to NULL
  • Tried setting it in Row_Inserting with…
    $newRow["regdate"] = date('Y-m-d H:i:s');
    but that gives a type mismatch.
  • This led me to trying
    $newRow["regdate"] = DateTimeImmutable::createFromFormat('Y-m-d H:i:s',date('Y-m-d H:i:s'));
    … but this gives an entirely different type mismatch!

So - how do I simply enter the current DATETIME in a field?

Thanks

This topic should help you.

Just what I needed - thank you!