开发者

How to format 2010-11-24 date in C#?

I am using

((DateTime)newsItem.Date).ToString(@"yyyy MM dd") 

which giv开发者_JAVA技巧es me 2010 11 24 but not 2010-11-24.

I want dashes in between the numbers of date.


Have you tried

((DateTime)newsItem.Date).ToString(@"yyyy-MM-dd");

Also, since you format the time part away anyway in the ToString, you don't need to add .Date, and you can change it to

((DateTime)newsItem).ToString(@"yyyy-MM-dd");


https://web.archive.org/web/20211020131217/https://www.4guysfromrolla.com/articles/111010-1.aspx This will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜