如何获得今天的C#日期2008年8月28日格式? [英] How do I get today's date in C# in 8/28/2008 format?
问题描述
我如何得到今天的C#日期2008年8月28日格式?
我需要一个字符串变量设置为今天的日期(最好没有年) ,但一定是比建设是一个月一个更好的方式 - / - 一天的时间一块
BTW:我在美国那么M / DD会是正确的,例如: 。9月11日是9月11日
的注:从kronoz的答案排在所讨论的国际化,我想这已经足够真棒提,因为我可以' ŧ使它成为'接受'回答为好。的
DateTime.Now.ToString(M / D / YYYY);
的 http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
How do I get today's date in C# in 8/28/2008 format?
I need to set a string variable to today's date (preferably without the year), but there's got to be a better way than building it month-/-day one piece at a time.
BTW: I'm in the US so M/dd would be correct, e.g. September 11th is 9/11.
Note: an answer from kronoz came in that discussed internationalization, and I thought it was awesome enough to mention since I can't make it an 'accepted' answer as well.
DateTime.Now.ToString("M/d/yyyy");
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
这篇关于如何获得今天的C#日期2008年8月28日格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!