internet上得到的时间字符串12:13:54 2002-9-24,如何转化为tdatetime型,如果不截取字符串的话
我这样做觉得太繁了,有人知道简单的吗?
procedure TForm1.FormCreate(Sender: TObject);
var
NMDayTime1: TNMDayTime;
currentTime:TSystemTime;
i:integer;
str:String;
begin
NMDayTime1:=TNMDayTime.Create(self);
NMDayTime1.Host:='202.109.114.209';
NMDayTime1.Port:=13;
Label1.Caption:=NMDayTime1.DayTimeStr;
Edit1.Text:=Label1.Caption;
str:=copy(Label1.Caption,0,8);
DecodeTime(StrToTime(str),CurrentTime.wHour,CurrentTime.wMinute,
CurrentTime.wSecond,CurrentTime.wMilliseconds);
str:=copy(Label1.Caption,10,Length(Label1.Caption)-7);
DecodeDate(StrToDate(trim(str)),CurrentTime.wYear,CurrentTime.wMonth,
CurrentTime.wDay);
SetLocaltime(currentTime);
NMDayTime1.Destroy;
end;