convert datetime to date format dd/mm/yyyy

后端 未结 13 2095
你的背包
你的背包 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 18:53

    this is you need and all people

       string date  = textBox1.Text;
    
            DateTime date2 = Convert.ToDateTime(date);
            var date3 = date2.Date;
            var D = date3.Day;
          var M =  date3.Month;         
          var y = date3.Year;
          string monthStr = M.ToString("00");
          string date4 = D.ToString() + "/" + monthStr.ToString() + "/" + y.ToString();
    
    
          textBox1.Text = date4;
    

提交回复
热议问题