function TFormMain.GetWeek: string;var date:SYSTEMTIME;begin GetLocalTime(date); case date.wDayOfWeek of 0:Result:='星期天'; 1:Result:='星期一'; 2:Result:='星期二'; 3:Result:='星期三'; 4:Result:='星期四'; 5:Result:='星期五'; 6:Result:='星期六'; end;end;
返回值为当天的星期几
function GetSubDateTime(S1, S2:string): string;var T1, T2: TDateTime; D, H, M, S: Integer; Value: Int64;begin T1 := StrToDateTime(S1); T2 := StrToDateTime(S2); Value := SecondsBetween(T1, T2); //两个时间之间相差的秒数 D := Value div SecsPerDay; H := Value mod SecsPerDay div SecsPerHour; M := Value mod SecsPerDay mod SecsPerHour div SecsPerMin; S := Value mod SecsPerDay mod SecsPerHour mod SecsPerMin; result := Format('%2d天 %.2d:%.2d:%.2d',[D, H, M, S]); // 返回几天:几时:几分:几秒end;