var
DateTime,MyDate,MyTime : TDateTime;
DateStr,TimeStr:string;
begin
DateTime := Now
//返回当前日期时间
DateStr:= DateToStr(DateTime)
//转换日期为字符串 ,例如:01/08/96
TimeStr := TimeToStr(DateTime)
//转换时间为字符串,例如:20:50
MyDate:= StrToDate(DateStr)
//转换字符串为日期
MyTime:= StrToTime(TimeStr)
//转换字符串为时间
DateTime:= MyDate + MyTime
//相加得到datetime
DateTime := DateTime + (15/60/24);//加15分钟
DateStr:= FormatDateTime('yyyy-mmmm-dd',MyDate)
{1996-January-08}
DateStr:= FormatDateTime('mmm,d,yy,ddd',MyDate)
{Jan,8,96,Mon}
DateStr:= FormatDateTime('dddd/dd/mm/yy',MyDate)
{Monday/08/01/96}
TimeStr:= FormatDateTime('t',MyTime)
{10:50 PM}
TimeStr:= FormatDateTime('tt',MyTime)
{10:50:00 PM}
TimeStr:= FormatDateTime('hh-nn-ss-a/p',MyTime)
{10-50-00-p}
end
////////////////////////////////////////////
begin
try {编码年月日为TDateTime}
DateTime := EncodeDate(YearStr, MonthStr,DayStr);
except
on EConvertError do ....
end;
DOW := DayOfWeek(DateTime)
获得星期几的信息
case DOW of
1 : WeekStr:= '星期天'
......
7:WeekStr:='星期六'
end;