If you have used Carbon Class in PHP, then you might have heard about the method Carbon::diffForHumans(). If the difference is more than 60 minutes, the output would be in hours and so on.

The Component had a prop of seconds which would hold the number of seconds that timer would need to display. Next I created an init method which would set the initial value of the timer.

Now, we would format the getTimeElapsed method so that it would return the data similar to Carbon method.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners