C 日期時間擷取

2021-08-31 12:01:42 字數 4122 閱讀 4031

關鍵字:c# 日期時間 擷取

datetime dt = datetime.now;

label11.text = dt.tostring();2005-11-5 13:21:25

label12.text = dt.tofiletime().tostring();127756416859912816

label13.text = dt.tofiletimeutc().tostring();127756704859912816

label14.text = dt.tolocaltime().tostring();2005-11-5 21:21:25

label15.text = dt.tolongdatestring().tostring();2023年11月5日

label16.text = dt.tolongtimestring().tostring();13:21:25

label17.text = dt.tooadate().tostring();38661.5565508218

label18.text = dt.toshortdatestring().tostring();2005-11-5

label19.text = dt.toshorttimestring().tostring();13:21

label10.text = dt.touniversaltime().tostring();2005-11-5 5:21:25

2005-11-5 13:30:28.4412864

label11.text = dt.year.tostring();2005

label12.text = dt.date.tostring();2005-11-5 0:00:00

label13.text = dt.dayofweek.tostring();saturday

label14.text = dt.dayofyear.tostring();309

label15.text = dt.hour.tostring();13

label16.text = dt.millisecond.tostring();441

label17.text = dt.minute.tostring();30

label18.text = dt.month.tostring();11

label19.text = dt.second.tostring();28

label10.text = dt.ticks.tostring();632667942284412864

label11.text = dt.timeofday.tostring();13:30:28.4412864

label11.text = dt.tostring();2005-11-5 13:47:04

label12.text = dt.addyears(1).tostring();2006-11-5 13:47:04

label13.text = dt.adddays(1.1).tostring();2005-11-6 16:11:04

label14.text = dt.addhours(1.1).tostring();2005-11-5 14:53:04

label15.text = dt.addmilliseconds(1.1).tostring();2005-11-5 13:47:04

label16.text = dt.addmonths(1).tostring();2005-12-5 13:47:04

label17.text = dt.addseconds(1.1).tostring();2005-11-5 13:47:05

label18.text = dt.addminutes(1.1).tostring();2005-11-5 13:48:10

label19.text = dt.addticks(1000).tostring();2005-11-5 13:47:04

label10.text = dt.compareto(dt).tostring();0

label11.text = dt.add(?).tostring();問號為乙個時間段

label11.text = dt.equals("2005-11-6 16:11:04").tostring();false

label12.text = dt.equals(dt).tostring();true

label13.text = dt.gethashcode().tostring();1474088234

label14.text = dt.gettype().tostring();system.datetime

label15.text = dt.gettypecode().tostring();datetime

label11.text = dt.getdatetimeformats(』s』)[0].tostring();2005-11-05t14:06:25

label12.text = dt.getdatetimeformats(』t』)[0].tostring();14:06

label13.text = dt.getdatetimeformats(』y』)[0].tostring();2023年11月

label14.text = dt.getdatetimeformats(』d』)[0].tostring();2023年11月5日

label15.text = dt.getdatetimeformats(』d』)[1].tostring();2005 11 05

label16.text = dt.getdatetimeformats(』d』)[2].tostring();星期六 2005 11 05

label17.text = dt.getdatetimeformats(』d』)[3].tostring();星期六 2023年11月5日

label18.text = dt.getdatetimeformats(』m』)[0].tostring();11月5日

label19.text = dt.getdatetimeformats(』f』)[0].tostring();2023年11月5日 14:06

label10.text = dt.getdatetimeformats(』g』)[0].tostring();2005-11-5 14:06

label10.text = dt.getdatetimeformats(』r』)[0].tostring();sat, 05 nov 2005 14:06:25 gmt

label11.text = string.format("",dt);2005-11-5

label12.text = string.format("",dt);2023年11月5日

label13.text = string.format("",dt);2023年11月5日 14:23

label14.text = string.format("",dt);2023年11月5日 14:23:23

label15.text = string.format("",dt);2005-11-5 14:23

label16.text = string.format("",dt);2005-11-5 14:23:23

label17.text = string.format("",dt);11月5日

labe1l8.text = string.format("",dt);sat, 05 nov 2005 14:23:23 gmt

labe1l9.text = string.format("",dt);2005-11-05t14:23:23

label10.text = string.format("",dt);14:23

label11.text = string.format("",dt);14:23:23

label12.text = string.format("",dt);2005-11-05 14:23:23z

label13.text = string.format("",dt);2023年11月5日 6:23:23

label14.text = string.format("",dt);2023年11月

label15.text = string.format("",dt);2005-11-5 14:23:23

label16.text = string.format("",dt);

清風夜影寒:

C 日期 時間

c 標準庫沒有提供所謂的日期型別。c 繼承了 c 語言用於日期和時間操作的結構和函式。為了使用日期和時間相關的函式和結構,需要在 c 程式中引用 標頭檔案。有四個與時間相關的型別 clock t time t size t和tm。型別 clock t size t 和 time t 能夠把系統時間和...

C 日期 時間

c 標準庫沒有提供日期型別,c 繼承了c語言用於日期和時間操作的函式,所以在c 程式中需要引用標頭檔案。其中有四個與時間相關的型別 clock t time t size t tm,型別 clock t size t 和 time t 能夠把系統時間和日期表示為某種整數。而結構體型別tm則把日期和時...

C 日期 時間

c 標準庫沒有提供所謂的日期型別。c 繼承了 c 語言用於日期和時間操作的結構和函式。為了使用日期和時間相關的函式和結構,需要在 c 程式中引用 標頭檔案。有四個與時間相關的型別 clock t time t size t和tm。型別 clock t size t 和 time t 能夠把系統時間和...