Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Trying to include seconds in time dataformatstring fails

$
0
0

I have built a .Net Core 2.0 application that stores and displays various time values among other data types, but I have not been able to format the values to accept seconds. Here is my current code:

[Display(Name = "Leak Point Time")]
[DisplayFormat(DataFormatString = "{0:hh\\:mm}", ApplyFormatInEditMode = true)]
[DataType(DataType.Time)]
public TimeSpan? LeakPointTime { get; set; }

When I run this I am prompted to enter times along with the AM/PM values as if it is interpreting the formatting as {0:hh\\:mm tt}. (ie 12:34 AM) Is this expected default behavior? I attempted to use {0:hh\\:mm\\:ss} to display seconds, but I am not allowed to enter seconds. I found this as a suggested format when checking online, but obviously it is not working?  Ideally I would just like to be able to enter a time value in hh:mm:ss format. (ie 12:34:56)


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>