How to display a TimeSpan in MVC Razor
- by John Mitchell
So I have a duration in seconds of a video and I would like to display that duration in Razor.
Currently I am using
@TimeSpan.FromSeconds(item.Duration).ToString()
However the rest of the code I am using uses
@Html.DisplayFor(modelItem => item.Description)
Is there way to get the duration (currently an int) to display a as a timespan? using the @Html.DisplayFor syntax. The item.duration is pulling form a Entity Framework model which is held as a int in the database.