把分钟数转化成几小时几分钟(100 -> 01:40)
/// <summary>
/// 把分钟数转化成几小时几分钟(100 -> 01:40)
/// </summary>
/// <param name="minutes">待转化的分钟数</param>
/// <returns>几小时几分钟</returns>
string ConvertToTime(object minutes)
{
int M = 0;//待转化的分钟数;
int h = 0;//小时
int m = 0;//分钟
try
{
if (minutes.ToString() != "")
{
M = Convert.ToInt32(minutes);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
h = M / 60;
m = M % 60;
DateTime time = DateTime.Parse("00:00");
time = time.AddHours(h).AddMinutes(m);
string R = time.ToString("HH:mm");
if (R == "00:00")
{
R = ""; ;
}
return R;
}