The usual way would be to start a timer when the lights are switched ON, that when it expires turns the lights OFF. Not really related to storing last timestamp.
See
and many similar.
The usual way would be to start a timer when the lights are switched ON, that when it expires turns the lights OFF. Not really related to storing last timestamp.
See
and many similar.