Format mask for TimeStamp attribute

1

I need to display the value of the TIMEOUT attribute only HH: mm (hour and minutes). By including the masks below an error occurs:

The input string was not in an incorrect format.

I've tried both ways:

@dia.HORAINICIO.ToString(@"hh:mm tt")
@dia.HORAINICIO.ToString("{0:t}")

My Annotation date is as follows:

[Display(Name = "Hora Inicial:")]
[DataType(DataType.Time)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:HH:mm}")]
public TimeSpan HORAINICIO { get; set; }
    
asked by anonymous 02.11.2015 / 15:19

1 answer

2

Try without 'tt' in the mask.

string test ="08:00:00";
TimeSpan ts = TimeSpan.Parse(test);
Console.Write(ts.ToString(@"hh\:mm"));

I did a Fiddle for you, I think it will answer you.

    
02.11.2015 / 23:32