Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Timer Interval in seconds and minutes

Tags:

c#

.net

timespan

I can get in textbox the timer1 interval but it is in milliseconds how to convert in seconds or in minutes?

like image 704
Luca's Avatar asked Sep 09 '11 08:09

Luca's


People also ask

What is interval in timer?

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 ."

How do you convert milliseconds to seconds in Swift?

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.


2 Answers

var timeSpan = TimeSpan.FromMilliseconds(5000);

var seconds = timeSpan.TotalSeconds;
var minutes = timeSpan.TotalMinutes;
like image 69
Kirill Polishchuk Avatar answered Sep 20 '22 05:09

Kirill Polishchuk


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;
        }
like image 25
Soner Gönül Avatar answered Sep 19 '22 05:09

Soner Gönül