How to remove time portion of date in C# in DateTime object only?

后端 未结 30 3390
醉话见心
醉话见心 2020-11-22 09:08

I need to remove time portion of date time or probably have the date in following format in object form not in the form of string.

         


        
30条回答
  •  一生所求
    2020-11-22 09:49

    Use the method ToShortDateString. See the documentation http://msdn.microsoft.com/en-us/library/system.datetime.toshortdatestring.aspx

    var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00
    var dateOnlyString = dateTimeNow.ToShortDateString(); //Return 00/00/0000
    

提交回复
热议问题