.net 中日期时间字段的时间格式 [英] Time format of datetime field in .net
本文介绍了.net 中日期时间字段的时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个日期时间字段,显示日期时间为 11/03/14 12:00 AM.我如何将此时间转换为 00:00 而不是 12:00 AM.
i have a datetime field whih is showing date time as 11/03/14 12:00 AM.How can i convert this time to 00:00 instead of 12:00 AM.
我试过了
DateTime.ToString("hh:mm tt")
推荐答案
你需要先把它转换成DateTime
,然后你才能使用ToShortDateString
:
You need to convert it first to DateTime
, then you could use ToShortDateString
:
DateTime dt = DateTime.ParseExact("11/03/14 12:00 AM", "dd/MM/yy hh:mm tt", CultureInfo.InvariantCulture);
string result = dt.ToShortDateString();
阅读:http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
这篇关于.net 中日期时间字段的时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文