how to give format DateTime.Date?

前端 未结 7 650
滥情空心
滥情空心 2021-01-29 10:47

DateTime dt = DateTime.Now dt.Date is created to 31.10.2012 00:00:00 .it is created to dd.mm.yyyy format but i need dd/mm/yyyy. Can i use: return new DateTime(d.Year, d.Month

7条回答
  •  被撕碎了的回忆
    2021-01-29 11:27

    DateTime structure always has the Date and Time stored in it. If you need to extract the date alone as text you can do the following.

    var date = DateTime.Now.ToString("d");
    Console.WriteLine(date);
    

    This will print the date as in the format as specified by the culture set in the system. The list of standard datetime format strings supported by dotnet framework can be found here

提交回复
热议问题