C datetime format Daquan datetime dt = DateTime.Now; Label1.Text = dt. ToString ();//2005-11-5 13:21:25label2.text = dt. Tofiletime (). ToString ();//127756416859912816label3.text = dt. TOFILETIMEUTC (). ToString ();//127756704859912816label4.text = dt. ToLocalTime (). ToString ();//2005-11-5 21:21:25label5.text = dt. Tolongdatestring (). ToString ();//November 5, 2005 Label6.text = dt. Tolongtimestring (). ToString ();//13:21:25label7.text = dt. ToOADate (). ToString ();//38661.5565508218label8.text = dt. ToShortDateString (). ToString ();//2005-11-5label9.text = dt. Toshorttimestring (). ToString ();//13:21label10.text = dt. ToUniversalTime (). ToString ();//2005-11-5 5:21:25//2005-11-5 13:30:28.4412864label1.text = dt. Year.tostring ();//2005label2.text = dt. Date.tostring ();//2005-11-5 0:00:00label3.text = dt. Dayofweek.tostring ();//saturdaylabel4.text = dt. Dayofyear.tostring ();//309label5.text = dt. Hour.tostring ();//13label6.text = Dt.Millisecond.ToString ();//441label7.text = dt. Minute.tostring ();//30label8.text = dt. Month.tostring ();/11label9.text = dt. Second.tostring ();//28label10.text = dt. Ticks.tostring ();//632667942284412864label11.text = dt. Timeofday.tostring ();//13:30:28.4412864label1.text = dt. ToString ();//2005-11-5 13:47:04label2.text = dt. AddYears (1). ToString ();//2006-11-5 13:47:04label3.text = dt. AddDays (1.1). ToString ();//2005-11-6 16:11:04label4.text = dt. AddHours (1.1). ToString ();//2005-11-5 14:53:04label5.text = dt. Addmilliseconds (1.1). ToString ();//2005-11-5 13:47:04label6.text = dt. AddMonths (1). ToString ();//2005-12-5 13:47:04label7.text = dt. AddSeconds (1.1). ToString ();//2005-11-5 13:47:05label8.text = dt. AddMinutes (1.1). ToString ();//2005-11-5 13:48:10label9.text = dt. Addticks (1000). ToString ();//2005-11-5 13:47:04label10.text = Dt.compareto (dt). ToString ();//0//label11.text = dt. ADD (?). ToString ();//question mark is a time period Label1.Text = dt. Equals ("2005-11-6 16:11:04"). ToString ();//falselabel2.text = dt. Equals (DT). ToString ();//truelabel3.text = dt. GetHashCode (). ToString ();//1474088234label4.text = dt. GetType (). ToString ();//system.datetimelabel5.text = dt. GetTypeCode (). ToString ();//datetimelabel1.text = dt. Getdatetimeformats (' s ') [0]. ToString ();//2005-11-05t14:06:25label2.text = dt. Getdatetimeformats (' t ') [0]. ToString ();//14:06label3.text = dt. Getdatetimeformats (' y ') [0]. ToString ();//November 2005 Label4.text = dt. Getdatetimeformats (' D ') [0]. ToString ();//November 5, 2005 Label5.text = dt. Getdatetimeformats (' D ') [1]. ToString ();//2005 one 05label6.text = dt. Getdatetimeformats (' D ') [2]. ToString ();//week 62,005 05label7.text = dt. Getdatetimeformats (' D ') [3]. ToString ();//Saturday November 5, 2005 Label8.text = dt. Getdatetimeformats (' M ') [0]. ToString ();//November 5 label9.text = dt. Getdatetimeformats (' f ') [0]. ToString ();//November 5, 2005 14:06label10.text = dt. Getdatetimeformats (' g ') [0]. ToString ();//2005-11-5 14:06label11.text = dt. Getdatetimeformats (' R ') [0]. ToString ();//sat, 2005 14:06:25 Gmtlabel1.text =? String. Format ("{0:d}", dt);//2005-11-5label2.text =? String. Format ("{0:d}", dt);//November 5, 2005 Label3.text =? String. Format ("{0:f}", dt);//November 20055th 14:23label4.text =? String. Format ("{0:f}", dt);//November 5, 2005 14:23:23label5.text =? String. Format ("{0:g}", DT);//2005-11-5 14:23label6.text =? String. Format ("{0:g}", DT);//2005-11-5 14:23:23label7.text =? String. Format ("{0:m}", dt);//November 5 Label8.text =? String. Format ("{0:r}", DT);//sat, 2005 14:23:23 Gmtlabel9.text =? String. Format ("{0:s}", dt);//2005-11-05t14:23:23label10.text = string. Format ("{0:t}", dt);//14:23label11.text = string. Format ("{0:t}", dt);//14:23:23label12.text = string. Format ("{0:u}", DT);//2005-11-05 14:23:23zlabel13.text = string. Format ("{0:u}", dt);//November 5, 2005 6:23:23label14.text = string. Format ("{0:y}", dt);//November 2005 Label15.text = string. Format ("{0}", dt);//2005-11-5 14:23:23? Label16.text = string. Format ("{0:yyyymmddhhmmssffff}", DT); Yyyymm can be set, such as Label16.text = string. Format ("{0:YYYYMMDD}", DT);
C # datetime date formatting Daquan