Empty HTML Input field for time

Ugh. Here’s another one of those mySQL to SQL Server headaches while using Laravel 5.

One application I’m currently supporting has extremely simple schedule tracking for users.  My users table simply had days of the week, shift begin, and shift end.  See the related migration below.

Schema::table('users', function ($table) {
    $table->integer('monday')->default(0);
    $table->integer('tuesday')->default(0);
    $table->integer('wednesday')->default(0);
    $table->integer('thursday')->default(0);
    $table->integer('friday')->default(0);
    $table->integer('saturday')->default(0);
    $table->integer('sunday')->default(0);
    $table->time('shift_begin')->nullable();
    $table->time('shift_end')->nullable();
});

When I deployed the application, Laravel created the table with the datatype of time, with the precision of 7 decimals.  Below is what the bug looked like to the user after a modified user has previously been set to something like, 13:00:00 to 15:00:00 — both with 7 decimal places.

To fix the issue, I removed the precision from the time datatypes from shift_begin and shift_end.

Hope this helps someone else at some point.

Leave a Reply