how to give format DateTime.Date?

前端 未结 7 648
滥情空心
滥情空心 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:12

    Just the way to convert to string, DateTime itself has no format:

    var result = DateTime.Now.Date
                         .ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
    

提交回复
热议问题