I'm new to laravel carbon so I did several searches on internet but I didn't get any tutorial in which I can get how to update time field in mysql db using laravel carbon. If I store a time to time field how to change it every second? can it possible with carbon???
Asked
Active
Viewed 221 times
0
-
1When do you need it to update? If you update a resource, Laravel will automatically update the `updated_at` field for you. – Kenny Horna Jan 25 '19 at 16:04
-
no bro I have a quiz system I need it there so I need it to update time every second and from there I will return it to the view – Jan 25 '19 at 16:06
-
You need to update the value every second in the database? Because, if your intention is to show a countdown timer. you could do it with JS in your front-end. If this is the case, check [this answer](https://stackoverflow.com/questions/16129157/countdown-timer-using-moment-js) as a guide. – Kenny Horna Jan 25 '19 at 16:08
-
Bro first I thought to use JS but there is a fallback if user inspect the time so he will get more time to attempt quiz I need to update in dynamically – Jan 25 '19 at 16:10
-
is there any workaround with carbon? is carbon let us change it every second? – Jan 25 '19 at 16:11
-
1Is not necessary. You start the form and create a record in your database, there the `created_at` is set, then when the user complete the form you make a second request, you can validate this new request (using `now()` to get the time) so if `now()` minus `created_at` is higher than your limit, you null the evaluation and make whatever actions you want. – Kenny Horna Jan 25 '19 at 16:12