How do I get today's date in C# in mm/dd/yyyy format?

后端 未结 8 2008
长情又很酷
长情又很酷 2020-12-29 01:00

How do I get today\'s date in C# in mm/dd/yyyy format?

I need to set a string variable to today\'s date (preferably without the year), but there\'s got to be a bette

8条回答
  •  一整个雨季
    2020-12-29 01:11

    If you want it without the year:

    DateTime.Now.ToString("MM/DD");
    

    DateTime.ToString() has a lot of cool format strings:

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

提交回复
热议问题