开发者

Format a TimeSpan string

In the code i have :

gvRankings.DataSource = rankings.OrderBy(rg => rg.Swimtime).Take(100).ToArray();  
gvRankings.DataBind();  

(Swimtime here is a TimeSpan)

At the frontside i have

< asp:TemplateField HeaderText="Tijd" ItemStyle-CssClass="time" HeaderStyle-CssClass="smallheader">
< ItemTemplate><%# ("Swimtime")%>< /ItemTemplate>
< /asp:TemplateField>

I would like to format the swimtime like hh:mm:dd.ff but i have (after 2 hours o开发者_JAVA百科f trying) absolutely no idea how to do this.....


string.Format("{0:hh\\:mm\\:dd\\.ff}", yourTimeSpan)


You could cheat and use the Ticks property to create a DateTime and format that the way you want:

string formatedTime = new DateTime(swimTime.Ticks).ToString("hh:mm:dd.ff");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜