C 日期處理函式

2021-04-12 16:02:26 字數 1337 閱讀 8276

1、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 取中文年月日

string strymd=currenttime.tostring("d");

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

string strt=currenttime.tostring("t");

1.14 取當前時間,格式為:2003-09-23t14:46:48

string strt=currenttime.tostring("s");

1.15 取當前時間,格式為:2003-09-23 14:48:30z

string strt=currenttime.tostring("u");

1.16 取當前時間,格式為:2003-09-23 14:48

string strt=currenttime.tostring("g");

1.17 取當前時間,格式為:tue, 23 sep 2003 14:52:40 gmt

string strt=currenttime.tostring("r");

1.18獲得當前時間 n 天後的日期時間

datetime newday = datetime.now.adddays(100);

C 日期處理函式

posted on 2006 10 22 21 07 劍氣瀟瀟 閱讀 729 編輯收藏 1 datetime 數字型 system.datetime currenttime new system.datetime 1.1 取當前年月日時分秒 currenttime system.datetime.n...

日期處理函式

計算乙個日期相隔幾天的日期 param date,日期物件,可選引數,預設為系統當前時間 param interval,相隔天數,負數代表前幾天,正數代表後幾天,可選引數,預設為1 returns function nextday date,interval 把日期字串轉換成日期物件 param d...

mysql 日期處理 mysql日期處理函式

mysql自己有格式化日期格式的函式 date format date,format 根據format字串格式化date值。下列修飾符可以被用在format字串中 m 月名字 january december w 星期名字 sunday saturday d 有英語字首的月份的日期 1st,2nd,...