将时钟时间转换为分钟
答
如何像
totalMins = (60 * hrs) + mins + (secs/60)
答
获取时间使用的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);
答
我做了这个样子。感谢您的支持者。
我有视频的某个时间像这样的“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"))) %>
这对我来说非常合适。
你真的需要帮忙把东西乘以60 ...? – 2009-12-21 06:43:34