Here's the function i use to show time in HH:MM:SS by given time in seconds
It doesn't show AM/PM and doesn't detect next day (HH > 24), just because i didn't use that.
But it's easy to add
public string FormatTime(int ASecTime)
{
string res = "";
int hr = ASecTime / 3600;
int min = (ASecTime % 3600) / 60;
int sec = ASecTime % 60;
res += (hr >= 10)? hr.ToString() : "0" + hr.ToString();
res += ":";
res += (min >= 10)? min.ToString() : "0" + min.ToString();
res += ":";
res += (sec >= 10)? sec.ToString() : "0" + sec.ToString();
return res;
}
Use the DateTime(int, int, int) constructor. Someone showed a way of doing
this using the fromseconds method, but I don't know that off the top of my
head.
Chris
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.