I have a variable: string currentTime in the constructor:
currentTime = DateTime.Now.ToString("HH:mm:ss tt");
And in the event Form1_FormClosing i have:
currentTimeClosed = DateTime.Now.ToString("HH:mm:ss tt");
Now i want to calculate the diffrenece between the two strings times and get the time the user used something like currenttimeClosed - currentTime = 10 minutes and 10 seconds
So i know the user used the program 10 minutes and 10 seconds.
How can i do it ?
First off, you don’t need to store strings – just store the
DateTimedirectly.You can subtract the two to get a
TimeSpantelling you the difference and output the value of that.