C# convert date to string
Last modified: June 29, 2021static void Main(string[] args)
{
var today = DateTime.Now;
var date1 = today.ToShortDateString(); //ouput 29/6/2021
var date2 = today.ToString("dd-MM-yy"); // output 29-06-21
var date3 = today.ToString("D"); // output Tuesday, 29 June 2021
var date4 = today.ToString("m"); //output 29 June
var date5 = today.ToString("y"); //ouput June 2021
var date6 = today.Year; //get current year
var date7 = today.Month; //get current month
}