how to count a signal (230V trough relay) in seconds and remember it

hello

I am just starting to know the arduino code and I am working on a project where I need to count the time that the signal was held and remember it, so that it could be used forward in the program.
I will be digging on but I would be really happy if I get some respond

by

millis()

If relay closed
Starttime = millis()

Do other stuff if required

If relay opened
Finishtime = millis()

Ontime = finishtime- starttime

Weedpharma