I am currently taking 2 dates from a database and finding the difference between them. I am displaying the value from the sum in my view page but it is currently showing as a decimal. For example, one of the values that gets produced is 1585.913 but I would like that in HH:MM:SS format.
My current code that displays the decimal value is as follows.
Controller
public ActionResult Execution(int id = 0)
{
Execution execution = db.Executions.Find(id);
if (execution == null)
{
return HttpNotFound();
}
ViewBag.ExecutionSeconds = (execution.End - execution.Start).TotalSeconds;
return View(execution);
}
View
@ViewBag.ExecutionSeconds
What changes to this code would I have to make in order for it to display the value in HH:MM:SS format?
Thanks in advance.