C 獲取時間

2021-10-14 04:14:27 字數 872 閱讀 5321

--datetime 數字型

system.datetime currenttime=new system.datetime();

1.1 取當前年月日時分秒

currenttime=system.datetime.now;

1.2 取當前年

int 年=currenttime.year;

1.3 取當前月

int 月=currenttime.month;

1.4 取當前日

int 日=currenttime.day;

1.5 取當前時

int 時=currenttime.hour;

1.6 取當前分

int 分=currenttime.minute;

1.7 取當前秒

int 秒=currenttime.second;

1.8 取當前毫秒

int 毫秒=currenttime.millisecond;

(變數可用中文)

1.9 取中文日期顯示——年月日時分

string stry=currenttime.tostring(「f」); //不顯示秒

1.10 取中文日期顯示_年月

string strym=currenttime.tostring(「y」);

1.11 取中文日期顯示_月日

string strmd=currenttime.tostring(「m」);

1.12 取當前年月日,格式為:2003-9-23

string strymd=currenttime.tostring(「d」);

1.13 取當前時分,格式為:14:24

string strt=currenttime.tostring(「t」);

C 獲取時間

獲取日期 時間 datetime.now.tostring 2008 9 4 20 02 10 datetime.now.tolocaltime tostring 2008 9 4 20 12 12 獲取日期 datetime.now.tolongdatestring tostring 2008年9...

C 獲取時間

獲取日期 時間 datetime.now.tostring 2008 9 4 20 02 10 datetime.now.tolocaltime tostring 2008 9 4 20 12 12 獲取日期 datetime.now.tolongdatestring tostring 2008年9...

C 獲取時間

c 獲取時間 標頭檔案 chrono,命名空間 std.現在時間 std chrono system clock now 返回系統時鐘的當前時間 時鐘std chrono system clock 代表系統當前的時間,是不穩定的時鐘,並且提供了函式可將時間點轉化為 time t 型別的值 std c...