Use Database NOW() in setting value on preCreate
Use Database NOW() in setting value on preCreate

Hello,
I would like to set a timestamp before creating a record using the database time stamp value.
Therefore insted of setting time like this
->on( 'preCreate', function ( $editor, $values ) {
$editor
->field( 'datetime_created' )->setValue( '2014-03-19 11:44:40' );
} )
I intend to set it like this
->on( 'preCreate', function ( $editor, $values ) {
$editor
->field( 'datetime_created' )->setValue( 'NOW()' );
} )
Any help?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Should do the business I think.
Another option is to use the
.
DEFAULT
option in your SQL column and have itDEFAULT now()
rather than needing PHP to do it. Personally that's the way I would do itAllan