24-hour Data-Time format

0

I need to change the data-time format to 24 hours.

I'm working with C # MVC5

This is my Model

[Display(Name = "Fecha y Hora de Inicio")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
public System.DateTime fechaHoraInicio { get; set; }

My Views

 @Html.TextBoxFor(model => model.fechaHoraInicio, new { type = "datetime-local" })

I already appreciate the interest.

    
asked by ALEXIS LOZADA 02.05.2017 в 20:23
source

2 answers

1

Use the upper-case HH function for the 24h format:

String s = curr.ToString("HH:mm");

more explanation: DateTime: toString

    
answered by 02.05.2017 в 23:13
0

You can try this:

[ Display(Name = "Fecha y Hora de Inicio") ]
[ DataType(DataType.Date), DisplayFormat(DataFormatString  =  @"{0:dd\/MM\/yyyy HH:mm}",  ApplyFormatInEditMode = true) ]
    
answered by 02.05.2017 в 21:37