php – Laravel carbon coutdown-ThrowExceptions

Exception or error:

Please tell me, i need to display a countdown timer on the Laravel blade page. The timer should not be reset when the page is refreshed. The timer should be updated every 24 hours by itself.

That is, I have an event that goes on exactly 24 hours, when the day ends, I have another event and I need the timer to reset to zero and show 24 hours again. How can this be implemented?

How to solve:

Here is how it can be implemented using Carbon:

1) In your controller, grab the current event and calculate the time left between the current timestamp and the event finishing time.

2) Save the result in a variable and pass the variable to the view.

3) In the view, format the time as required to make it look the way you want.

4) If you want to update the timer dynamically in the view, use some javascript for to decrement the time every hour.

Leave a Reply

Your email address will not be published. Required fields are marked *