資源描述:
《delphi日期函數(shù)、日期加減》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、delphi日期函數(shù)、日期加減2008-02-2909:12Delphi里有現(xiàn)成的函數(shù)可以實(shí)現(xiàn)日期加減,是在DateUtils單元里的。functionIncYear(constAValue:TDateTime;constANumberOfYears:Integer=1):TDateTime;//functionIncMonthisinSysUtilsfunctionIncWeek(constAValue:TDateTime;constANumberOfWeeks:Integer=1):TDateTime;functionIncDay(constAValue:TD
2、ateTime;constANumberOfDays:Integer=1):TDateTime;functionIncHour(constAValue:TDateTime;constANumberOfHours:Int64=1):TDateTime;functionIncMinute(constAValue:TDateTime;constANumberOfMinutes:Int64=1):TDateTime;functionIncSecond(constAValue:TDateTime;constANumberOfSeconds:Int64=1):TDateTim
3、e;functionIncMilliSecond(constAValue:TDateTime;constANumberOfMilliSeconds:Int64=1):TDateTime;Day開頭的函數(shù)●UnitDateUtilsfunctionDateOf(constAvalue:TDateTime):TDateTime;描述使用DateOf函數(shù)用來把一個(gè)TDateTime類型的變量轉(zhuǎn)變成一個(gè)只帶有日期的TDateTime類型變量。例如:showmessage(DateTimetostr(dateof(now())));你得到的是2003/03/19而showm
4、essage(DateTimetostr((now())));得到的是2003/03/1910:50:49●functionDateTimeToStr(DateTime:TDateTime):string;描述DateTimeToString函數(shù)將TDateTime類型的參數(shù)DateTime轉(zhuǎn)換成一個(gè)字符串,使用給定的全局變量ShortDateFormat的格式,時(shí)間部分按照給定的全局變量LongTimeFormat的格式。其中DateTime為零的部分將不會(huì)顯示出來。例如:ShortDateFormat:=’yyyymmdd’;showmessage(DateT
5、imetostr((now())));你將得到:2003031910:50:49●procedureDateTimeToString(varResult:string;constFormat:string;DateTime:TDateTime);描述:DateTimeToString方法將TDateTime類型的參數(shù)DateTime按照由參數(shù)Format提供的格式轉(zhuǎn)化成字符串,并保存在Result中。對(duì)于Format的格式類型,請(qǐng)看Date-Timeformatstrings的幫助。例如:DateTimeToString(result,’yyyymmdd’,now
6、());那么result的結(jié)果為:2003031910:50:49●procedureDateTimeToSystemTime(DateTime:TDateTime;varSystemTime:TSystemTime);描述:有時(shí)為了調(diào)用API函數(shù)來使用系統(tǒng)時(shí)間,你可以使用DateTimeToSystemTime方法,來將一個(gè)TDateTime類型的時(shí)間變量轉(zhuǎn)換成一個(gè)TSystemTime類型的系統(tǒng)時(shí)間?!駀unctionDateTimeToUnix(constAvalue:TDateTime):Int64;描述:使用DateTimeToUnix函數(shù)來將一個(gè)TDa
7、teTime型時(shí)間變量轉(zhuǎn)換成一個(gè)相應(yīng)的Unix格式的日期和時(shí)間。Unixdate-and-timevaluesareencodedasthenumberofsecondsthathaveelapsedsincemidnightatthestartofJanuary1,1970.●functionDateToStr(Date:TDateTime):string;描述:使用DateToStr函數(shù)能得到TDateTime日期時(shí)間類型的日期部分。日期的轉(zhuǎn)換格式依賴于全局變量ShortDateFormat?!駀unctionDayOf(constAvalue:TDateTi
8、me):W