If I have the following string representing a time:
var s = "22:01:15";
I want to increment that time along with the system clock, but add to my existing value.
How do I continue this as if it was a real clock no matter what the actual computer clock time is?
Just take that time, parse it into a
Dateinstance, and determine the difference between that and the system’s date. Then apply that offset.Parse it:
Apply that to a date
Get the difference
Apply it any time you’re going to display the value
Use the
nowinstance to displayYou do steps 1 – 4 once, at the outset; then repeat step 5 as necessary.
Live example