*显示出时间
FormatDateTime('yyyy"年"m"月"d"日 "dddd '+ 'hh:mm:ss AM/PM', Now);
Year := FormatDateTime('YYYY',Date);
Month := FormatDateTime('MM',Date);
Day := FormatDateTime('DD',Date);
---显示星期几-------------------------------------------------
case DayOfWeek(Now) of
1:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期日';
2:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期一';
3:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期二';
4:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期三';
5:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期四';
6:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期五';
7:label1.Caption:='今天是 '+FormatDateTime('yyyy年mm月dd日',Now())+' 星期六';
end;
---------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject); //年月日时分分离
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := '今天是'+IntToStr(Year)+'年'+IntToStr(Month)+'月'+IntToStr(Day)+'日';
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := '现在是'+IntToStr(Hour)+'时'+IntToStr(Min)+'分';
end;
//==================================================================
*TDateTime TDate 类
Now 返回当前日期及时间
Date 返回当前日期
Time 返回当前时间
DateTimeToStr 按缺省格式将日期和时间值转换为字符串;特定格式转换可用 FormatDateTime函数
DateTimeToString 按缺省格式将日期和时间值拷贝到字符串缓冲区
DateToStr 将TDateTime值的日期部分转为字符串
TimeToStr 将TDateTime值的时间部分转为字符串
FormatDateTime 按特定格式将日期和时间值转换为字符串
StrToDateTime 将带有日期和时间信息的字符串转换为TdateTime类型值,如串有误将引发一个异常
StrToDate 将带有日期信息的字符串转换为TDateTime类型格式
StrToTime 将带有时间信息的字符串转换为TDateTime类型格式
DayOfWeek 根据传递的日期参数计算该日期是一星期中的第几天
DecodeDate 根据日期值返回年、月、日值
DecodeTime 根据时间值返回时、分、秒、毫秒值
EncodeDate 组合年、月、日值为TDateTime类型值
EncodeTime 组合时、分、秒、毫秒值为TDateTime类型值