Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sama's avatar
Level 1

Insert date and time in Database Laravel 5.4

Hello everyone I am a beginner in laravel and I do not know how I can do to insert in the data base the date of the day and the time when the user has to click a button if you have a tutorial that can help me you can propose it and thank you in advance

0 likes
2 replies
pardeepkumar's avatar
Schema::create('assgtask', function(Blueprint $table)
 {
   ...
   $table->timestamps();
 });


public static function boot()
      {

           public $timestamps = false;

           parent::boot();

           static::creating(function($model) {
              $dt = new DateTime;
              $model->created_at = $dt->format('m-d-y H:i:s');
              return true;
           });

          

Please or to participate in this conversation.