Many time we need to convert total seconds to Hour, Minute,second format. Here is a simple implementation.
int totalSecondsInt, tempH, tempM, tempS;
decimal totalSecondsDec = Convert.ToDecimal(totalSecondsInt);
tempH = Convert.ToInt32(totalSecondsDec / 3600);
tempM = Convert.ToInt32(Math.Floor(((totalSecondsDec / 3600) - Convert.ToInt16((totalSecondsDec / 3600))) * 60));
tempS = Convert.ToInt32(Math.Floor(totalSecondsDec % 60));
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment