What is the way to record and calculate time?
I want to create a method that takes two variables timeIn and timeOut and compares the time between them to draw the difference.
How can I make it so that this timeIn is currently recorded and timeOut is also the time for the current date? It's as if I checked into the parking lot and then check the sorting.
Can I take timeOut and subtract it from timeIn to get the difference?
I am using C # code.
source to share
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" );
change
INCORRECT OPERATING TIME
The ticks presented in Stopwatch
are based on a combination of machine hardware and operating system. Compare this with TimeSpan
where it Ticks
is defined as 100 nanosecond intervals
- it is obviously machine / OS independent .
source to share