How to find a time between two events

Hi all,

I'm working on a project and need to find the time elapsed between two events. I'm finding it hard because I don't know how to restart a timer when needed. I understand how to use the millis() and micro() functions but am still finding it quite difficult. Any help would be greatly appreciated! Thank you!

I look at the wall clock, and note that the second hand is pointing to the 2.
I turn off the WiFi router.
My daughter yells out that the internet is down.
I look at the clock, and the second hand is pointing to the 9.

We can assume that this interaction took less than a minute, so what is the elapsed time, and how did you calculate it?

But why would you do this to your daughter?

Maybe you are trying to hint she should get out and do some physical activity.

Oh this is so confusing. :frowning:

There are examples in the Tutorial forum.

Show us your attempts.

"I'm finding it hard because I don't know how to restart a timer when needed.

I think the millis timer will reset on its own after a number of days. Just get the current millis when the event starts and save it as a start time variable, then get the millis when the event ends and save it as an end time variable, then subtract the start from the end to get the lapsed time.

"I think the millis timer will reset on its own after a number of days. "

Yes, 49 days.

Or after a power loss.

Or after a Reset.