如何获得今天的C#日期2008年8月28日格式? [英] How do I get today's date in C# in 8/28/2008 format?

查看:136
本文介绍了如何获得今天的C#日期2008年8月28日格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何得到今天的C#日期2008年8月28日格式?



我需要一个字符串变量设置为今天的日期(最好没有年) ,但一定是比建设是一个月一个更好的方式 - / - 一天的时间一块



BTW:我在美国那么M / DD会是正确的,例如: 。9月11日是9月11日



注:从kronoz的答案排在所讨论的国际化,我想这已经足够真棒提,因为我可以' ŧ使它成为'接受'回答为好。



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.

kronoz's answer

解决方案

DateTime.Now.ToString("M/d/yyyy");

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

这篇关于如何获得今天的C#日期2008年8月28日格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆