2011-09-09 170 views

回答

8
var timeSpan = TimeSpan.FromMilliseconds(5000); 

var seconds = timeSpan.TotalSeconds; 
var minutes = timeSpan.TotalMinutes; 
+0

我有在timer1.interval插入textbox1.text變化5000 = seconds.tostring();和工作!非常感謝 –

1

利用TimeSpan做的工作對你

C# Convert Milliseconds, Seconds, Minutes

嘗試

public string getFormattedTimeFromMilliSecond(double milliSecond) 
    { 

     TimeSpan t = TimeSpan.FromMilliseconds(milliSecond); 

     string formatedTime = string.Format("{0:D2}H:{1:D2}M:{2:D2}S", 
           t.Hours, 
           t.Minutes, 
           t.Seconds); 

     return formatedTime; 
} 
0

毫秒到幾秒

seconds = myMillisecondValue /1000; 

毫秒到分鐘

minutes = myMillisecondValue /60000; 
1

檢查TimeSpan Methods

public static double ConvertMillisecondsToSeconds(double milliseconds) 
     { 
     return TimeSpan.FromMilliseconds(milliseconds).TotalSeconds; 
     } 


    public static double ConvertMillisecondsToMinutes(double milliseconds) 
     { 
     return TimeSpan.FromMilliseconds(milliseconds).TotalMinutes; 
     } 
相關問題