1292 Incorrect datetime value:

1292 Incorrect datetime value:

mmurangwammurangwa Posts: 2Questions: 1Answers: 0

Good Day

Am trying to save a date value to a MySQL database and am getting the error below.
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2017-01-26T16:15:27+02:00' for column 'create_date' at row 1

the code setting the date value is

    ->on('preCreate', function ( $editor, $values ) {
        $editor
        ->field('members.creator_id')
        ->setValue($_SESSION['user_id']);
        $editor
        ->field('members.create_date')
        ->setValue(date('c'))
        ->getFormatter( 'Format::date_sql_to_format', 'Y-m-d H:i:s' );
    })

@GLOBAL.sql_mode is set to
STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION

and it can not be changed.

@GLOBAL.sql_mode setting.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin
    Answer ✓

    I think you probably want to use:

    ->setValue(date('Y-m-d H:i:s'))
    

    Allan

  • mmurangwammurangwa Posts: 2Questions: 1Answers: 0

    Worked thanks Allan

This discussion has been closed.