使用pm和am显示的日期时间

时间:2015-09-03 12:27:54

标签: c# datetime

[DisplayName("Date")]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd hh:mm:ss}")]
public DateTime? Date { get; set; }
  

日期是:2015-09-03 14:22:43

     

但它显示为:2015-09-03 02:22:43

如何将其显示为2015-09-03 14:22:43?

2 个答案:

答案 0 :(得分:2)

HH的{​​p> 00-24 hourshh的{​​{1}}

所以,替换

AM/PM

[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd hh:mm:ss}")]

答案 1 :(得分:1)

您可以尝试:

[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd HH:mm:ss}")]
                                                 ^^
                                                  |___ This will specify the time as 24hours
相关问题