convert datetime to date format dd/mm/yyyy

后端 未结 13 2090
你的背包
你的背包 2020-11-27 18:14

I have a DateTime object 2/19/2011 12:00:00 AM. I want to convert this object to a string 19/2/2011.

Please help me to convert DateTime to

13条回答
  •  被撕碎了的回忆
    2020-11-27 19:02

    First of all, you don't convert a DateTime object to some format, you display it in some format.

    Given an instance of a DateTime object, you can get a formatted string in that way like this:

    DateTime date = new DateTime(2011, 2, 19);
    string formatted = date.ToString("dd/M/yyyy");
    

提交回复
热议问题