C# DateTime.Tostring()格式
string dateTime1 = DateTime.Now.ToString("D");
Console.WriteLine(dateTime1);
string dateTime2 = DateTime.Now.ToString("d");
Console.WriteLine(dateTime2);
string dateTime3 = DateTime.Now.ToString("F");
Console.WriteLine(dateTime3);
string dateTime4 = DateTime.Now.ToString("f");
Console.WriteLine(dateTime4);
string dateTime5 = DateTime.Now.ToString("G");
Console.WriteLine(dateTime5);
string dateTime6 = DateTime.Now.ToString("g");
Console.WriteLine(dateTime6);
string dateTime7 = DateTime.Now.ToString("T");
Console.WriteLine(dateTime7);
string dateTime8 = DateTime.Now.ToString("t");
Console.WriteLine(dateTime8);
string dateTime9 = DateTime.Now.ToString("U");
Console.WriteLine(dateTime9);
string dateTime10 = DateTime.Now.ToString("u");
Console.WriteLine(dateTime10);
string dateTime11 = DateTime.Now.ToString("m");
Console.WriteLine(dateTime11);
string dateTime12 = DateTime.Now.ToString("M");
Console.WriteLine(dateTime12);
string dateTime13 = DateTime.Now.ToString("r");
Console.WriteLine(dateTime13);
string dateTime14 = DateTime.Now.ToString("R");
Console.WriteLine(dateTime14);
string dateTime15 = DateTime.Now.ToString("y");
Console.WriteLine(dateTime15);
string dateTime16 = DateTime.Now.ToString("Y");
Console.WriteLine(dateTime16);
string dateTime17 = DateTime.Now.ToString("o");
Console.WriteLine(dateTime17);
string dateTime18 = DateTime.Now.ToString("O");
Console.WriteLine(dateTime18);
string dateTime19 = DateTime.Now.ToString("s");
Console.WriteLine(dateTime19);
string dateTime20 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
Console.WriteLine(dateTime20);
string dateTime21 = DateTime.Now.ToString("yyyy年MM月dd HH时mm分ss秒");
Console.WriteLine(dateTime21);
string dateTime22 = DateTime.Now.ToString("dddd, MMMM dd yyyy");
Console.WriteLine(dateTime22);
string dateTime23 = DateTime.Now.ToString("ddd, MMM d \"'\"yy");
Console.WriteLine(dateTime23);
string dateTime24 = DateTime.Now.ToString("dddd, MMMM dd");
Console.WriteLine(dateTime24);
string dateTime25 = DateTime.Now.ToString("M/yy");
Console.WriteLine(dateTime25);
string dateTime26 = DateTime.Now.ToString("dd-MM-yy");
Console.WriteLine(dateTime26);
string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
string dateTime27 = DateTime.Now.AddDays(-1).ToShortDateString();
Console.WriteLine(dateTime27);
string dateTime28 = DateTime.Now.AddDays(1).ToShortDateString();
Console.WriteLine(dateTime28);
string dateTime29 = DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString();
Console.WriteLine(dateTime29);
string dateTime30 = DateTime.Now.AddDays(Convert.ToDouble((6 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString();
Console.WriteLine(dateTime30);
string dateTime31 = Day[Convert.ToInt16(DateTime.Now.DayOfWeek)];
Console.WriteLine(dateTime31);
string dateTime32 = DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWeek))) - 7).ToShortDateString();
Console.WriteLine(dateTime32);
string dateTime33 = DateTime.Now.AddDays(Convert.ToDouble((6 - Convert.ToInt16(DateTime.Now.DayOfWeek))) - 7).ToShortDateString();
Console.WriteLine(dateTime33);
string dateTime34 = DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWeek))) + 7).ToShortDateString();
Console.WriteLine(dateTime34);
string dateTime35 = DateTime.Now.AddDays(Convert.ToDouble((6 - Convert.ToInt16(DateTime.Now.DayOfWeek))) + 7).ToShortDateString();
Console.WriteLine(dateTime35);
string dateTime36 = DateTime.Now.ToString("yyyy-MM-01");
Console.WriteLine(dateTime36);
string dateTime37 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(1).AddDays(-1).ToShortDateString();
Console.WriteLine(dateTime37);
string dateTime38 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(-1).ToShortDateString();
Console.WriteLine(dateTime38);
string dateTime39 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(1).ToShortDateString();
Console.WriteLine(dateTime39);
Console.ReadKey();