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

后端 未结 30 3957
醉话见心
醉话见心 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:37

    None of the above answers solved my problem on winforms.

    the easiest way to reach ONLY date is the simple function in Datetime:

    DateTime dt = DateTime.now;
    String BirthDate = dt.ToShortDateString();
    

    You will only have date in Birthday string .

提交回复
热议问题