2011-10-01 59 views
1

看似简单。我需要将DateTime对象转换为没有时间戳的字符串。如何将DateTime对象转换为仅使用C#日期的字符串?

这给了我日期和时间。而我无法弄清楚如何获得日期。

 startDate = Convert.ToString(beginningDate); 

此输出:2011年10月1日12:00:00 AM

我需要的是:2011年10月1日作为一个字符串

任何帮助表示赞赏。

+0

可能重复的[如何仅显示日期组件](http://stackoverflow.com/questions/ 4111606/how-to-date-date-with-just-the-date-component) –

回答

0

你可以做这样的事情;

DateTime dt = beginningDate; StringBuilder sbDate = Convert.toString(dt.year); //以及对其他月份和日期

相关问题