B
B
BonBon Slick2017-02-13 17:05:35
PostgreSQL
BonBon Slick, 2017-02-13 17:05:35

Datetime field overflow: 7 ERROR: date/time field value out of range?

Laravel 5.4
PostgreSQL 9.6
Migration code:

Schema::create('roles', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->string('name', 55)->unique();
            $table->string('description', 255)->nullable();
            $table->timestamps();
        });

Seeider's code:
DB::table( 'roles' )->insert ( [
       'name' => 'admin',
       'created_at' => date( 'd-m-y h:m:s' )
       ] );

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BonBon Slick, 2017-02-13
@BonBonSlick

$now_date = date('Y/m/d h:i:s', time());
      DB::table( 'roles' )->insert ( [
       'name' => 'admin',
       'created_at' => date($now_date)
       ] );

S
sokollondon, 2019-10-14
@sokollondon

If you want to use the date in queries, for example, in the format "01/01/2019", then you can add the line to the postgresql config:
And the error will disappear =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question