Barney wrote:
in my db i have the time as seconds, 3600, 1800, etc. how can i convert that
to the actual time and display it as 1:00 AM, etc?
thx
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;
}
Hope it helps,
Andrey