从一个日期/时间字符串删除时间时间、字符串、日期

由网友(错过的所有。)分享简介:我有日期和时间存储在我的数据库,我不希望同时显示,只是日期本身。当我存储日期/时间在变,我怎么输出只是日期在C#?I have date and time stored in my database and I don't want to display both, just the date itself. Whe...

我有日期和时间存储在我的数据库,我不希望同时显示,只是日期本身。当我存储日期/时间在变,我怎么输出只是日期在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#?

推荐答案

这是非常有用的:

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);  
阅读全文

相关推荐

最新文章