public string SecToTime(int InSecond)
{
int years = 0;
int Days = 0;
int Hours = 0;
int Minutes = 0;
int Seconds = 0;
if (InSecond >= 31556926)
{
years = Convert.ToInt32(InSecond / 31556926);
InSecond = (InSecond % 31556926);
}
if (InSecond >= 86400)
{
Days = Convert.ToInt32(InSecond / 86400);
InSecond = (InSecond % 86400);
}
if (InSecond >= 3600)
{
Hours = Convert.ToInt32(InSecond / 3600);
InSecond = (InSecond % 3600);
}
if (InSecond >= 60)
{
Minutes = Convert.ToInt32(InSecond / 60);
InSecond = (InSecond % 60);
}
Seconds = Convert.ToInt32(InSecond);
if(years>0)
{
return string.Format("{0}年{1}天{2}小时{3}分{4}秒", years,Days, Hours, Minutes, Seconds);
}else if(Days>0)
{
return string.Format("{0}天{1}小时{2}分{3}秒", Days, Hours, Minutes, Seconds);
}
else if (Hours > 0)
{
return string.Format("{0}小时{1}分{2}秒", Hours, Minutes, Seconds);
}
else if (Minutes > 0)
{
return string.Format("{0}分{1}秒", Minutes, Seconds);
}
else
{
return string.Format("{0}秒", Seconds);
}
}