Trying to create stopwatch

Hi everyone! I'm new to arduino and this is only my second project ever--so any advice is welcome! (no idea if this is even feasible)
I'm essentially trying to create a "photogate" with an ultrasonic sensor. My goal is to be able to press a button or input something and have a timer start. The timer would then stop when the ultrasonic detects an object close enough and output the time to the serial monitor.
I've used the ultrasonic plenty of times and am familiar with that part of this idea, but I have no idea how to implement the "timer" part.
Again, I'm very new to this so please be patient and don't assume I know something, because I probably don't :slight_smile:

There's a function called millis() that will give you the amount of time in milliseconds since the board was last reset. If you record that in a variable at the start of the period and then record it again in another variable at the end then you can just subtract and you'll have the time between.

sounds easy enough, I'll give it a try! thanks