- you could face problems with long term running if you are have a variable that takes millis() value
this is obvious and clear*
Obvious and clear to those who who screw up their code and don't know it.
Both the millis() and micros() counters count up from 0 to over 4 billion before rolling over.
If you use unsigned subtraction of end time - start time you get the correct difference up to the amount that the unsigned integer variable can hold even if the end time is past rollover from the start time.
With unsigned long time variables the maximum difference is just over 49.7 DAYS.
With unsigned int variables the maximum difference is a bit over 65 MINUTES. 16 bit timers are smaller and run faster.
With byte variables it is just over 1/4 SECOND, I use byte timers for debouncing buttons because they are small and fast.
Look at a round clock. If the hour hand is on 3 and the start time was 10, to subtract 10 from 3 move the hour hand from 3 backwards (subtract) 10 hours and you get 5, the number of hours between 10 and 3. That is base 12 unsigned math in action, works for up to (12-1) hour differences.
The Arduino BlinkWithoutDelay Built-in Example sketch does mix signed and unsigned variables (long and unsigned long) in the sketch. It should bug at about 25 days... maybe that's supposed to be a lesson but I call it a poor example.
One member, Morris Dovey, wrote a time library that uses 64-bit type unsigned long long. It can time millis for billions of years, like when our sun bloats to red giant stage. So max possible interval can be larger than any practical need.