从日期时间的小时?在24小时内的格式 [英] Hour from DateTime? in 24 hours format
本文介绍了从日期时间的小时?在24小时内的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这个日期?我想做的事情是获得一小时,但显示它在24小时内的格式。结果
例如:结果
如果小时下午二时20分23秒,我想将其转换为14:20,仅此而已。
我在使用Visual C#的工作。
任何想法,请,谢谢。
我有这样的事情
公共静态字符串FormatearHoraA24(日期时间?fechaHora)
{
如果(!fechaHora.HasValue)
返回; 字符串retornar =;
//这里去我需要什么
}
解决方案
返回fechaHora.Value.ToString(HH:MM);
So i have this DateTime? and what i want to do is to obtain the hour but show it in 24 hours format.
For example:
If the hour is 2:20:23 p.m. i want to convert it to 14:20 and that's it.
I'm working with Visual C#. Any ideas please, thank you.
I have something like this
public static string FormatearHoraA24(DateTime? fechaHora)
{
if (!fechaHora.HasValue)
return "";
string retornar = "";
//here goes what i need
}
解决方案
return fechaHora.Value.ToString("HH:mm");
这篇关于从日期时间的小时?在24小时内的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文