从一个日期/时间字符串删除时间 [英] Remove time from a date/time string
本文介绍了从一个日期/时间字符串删除时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有日期和时间存储在我的数据库,我不希望同时显示,只是日期本身。当我存储日期/时间在变,我怎么输出只是日期在C#?
I have date and time stored in my database and I don't want to display both, just the date itself. When I store the date/time in a variable how do I output just the date in C#?
推荐答案
这是非常有用的:
<一个href="http://www.csharp-examples.net/string-format-datetime/">http://www.csharp-examples.net/string-format-datetime/
在你的情况下,我会说:
In you case I would say:
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);
String.Format("{0:MM/dd/yy}", dt);
这篇关于从一个日期/时间字符串删除时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文