I want to create a method that takes two variables timeIn and timeOut and compare the times between the two to draw a difference.
How can I make it so that that timeIn is recorded at time now, and timeOut would also be a time for the present date? It is as if I checked into a parking lot, and then check out sort thing.
Could I take timeOut and subtract it from timeIn to get the difference?
I am using c# code.
try this :
System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
doLogWork() ...
sw.Stop();
Console.Write( sw.Elapsed.TotalSeconds + " Sec / " +
((float)sw.Elapsed.TotalSeconds / (float)60).ToString("N2") +
" min" );
DONT USE TIMESPAN
ticks represented in Stopwatch
are based on a combination of the hardware of the machine and the operating system.
Contrast this to TimeSpan
where Ticks
are defined as 100 nanosecond intervals
-- which is obviously machine/OS independent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With