How to display a TimeSpan in MVC Razor

Posted by John Mitchell on Stack Overflow See other posts from Stack Overflow or by John Mitchell
Published on 2012-06-27T15:08:54Z Indexed on 2012/06/27 15:15 UTC
Read the original article Hit count: 883

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc