I can get in textbox the timer1 interval but it is in milliseconds how to convert in seconds or in minutes?
interval timer A digital circuit that is used to determine the time interval between an initial trigger pulse and subsequent logic states that appear after a predetermined delay. A Dictionary of Computing. "interval timer ."
To convert milliseconds to seconds, divide the number of milliseconds by 1000 and then call the Date(timeIntervalSince1970:) with the resulting seconds. To avoid having to do this every time, you can write an extension to do it.
var timeSpan = TimeSpan.FromMilliseconds(5000);
var seconds = timeSpan.TotalSeconds;
var minutes = timeSpan.TotalMinutes;
Check the TimeSpan Methods
.
public static double ConvertMillisecondsToSeconds(double milliseconds)
{
return TimeSpan.FromMilliseconds(milliseconds).TotalSeconds;
}
public static double ConvertMillisecondsToMinutes(double milliseconds)
{
return TimeSpan.FromMilliseconds(milliseconds).TotalMinutes;
}
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