2009-12-21 185 views

回答

1

如何像

totalMins = (60 * hrs) + mins + (secs/60) 
2

獲取時間使用的TimeOfDay方法的時間跨度值,然後使用TotalMinutes方法來獲取時間(分鐘):

DateTime t = new DateTime(0, 0, 0, 11, 21, 21); 
double minutes = t.TimeOfDay.TotalMinutes; 

的分鐘變量現在包含681.35。如果您想要的值作爲整個分鐘使用Math.Round或Math.Floor,這取決於你如何想它四捨五入:

int minutes = (int)Math.Floor(t.TimeOfDay.TotalMinutes); 
0

我做了這個樣子。感謝您的支持者。

我有視頻的某個時間像這樣的「1點22分03秒」有時這樣「55:43」

而且我這個時間轉換爲minudes這樣

public string converttomins(String val2) 
{ 
    int hrs, mins, secs; 
    int totalMins; 
    if (val2.Length > 6) 
    { 
     hrs = Convert.ToInt32(val2.Substring(0, 2)); 
     mins = Convert.ToInt32(val2.Substring(3, 2)); 
     secs = Convert.ToInt32(val2.Substring(6, 2)); 
     totalMins = (60 * hrs) + mins + (secs/60); 
    } 
    else 
    { 
     //hrs = Convert.ToInt32(val2.Substring(0, 2)); 
     mins = Convert.ToInt32(val2.Substring(0, 2)); 
     secs = Convert.ToInt32(val2.Substring(3, 2)); 
     totalMins = mins + (secs/60); 
    } 

    //Response.Write("<script>alert('" + Convert.ToString(totalMins) + "')</script>"); 
    return Convert.ToString(totalMins) + " dakika"; 
} 

我送我的像這樣的時間

<%# converttomins(Convert.ToString(Eval("sure"))) %> 

這對我來說非常合適。

相關問題