Help with Elapsed Time

I'm running a Node-red on RPI3 and need help with Elapsed Time:
I'm trying accomplish two things:
1.Get an input from the user about the date and time then calculate an elapsed time from that point forward. I want to save the users input so in case of a blackout the count will continue from the users input point.
The output of the count should include days, hours, minutes and seconds of the elapsed time and also a reset button for the users input data in order to put new date and time.
2.I have a photosensitive module connected to the RPI and I want count elapsed time when there is light and again when it is dark with the same format: days, hours, minutes and seconds stating how long there were light an how long darkness.

Thanks in advance

Would it help to know that a date/time value in JavaScript is a number of milliseconds from a fixed point in the past?

So you can simply subtract a starting value from now to get an elapsed number of milliseconds that you can then convert as you like.