我找不到好办法,你先凑合着用吧! var buf:array[0..5] of byte; test:array[0..5] of integer; i:integer; s:string; begin buf[0]:=$03; buf[1]:=$06; buf[2]:=$0C; buf[3]:=$0E; buf[4]:=$28; buf[5]:=$10; for i:=0 to 5 do begin test[i]:=(buf[i]); if (i=3) or (i=4) then s:=s+inttostr(test[i])+':' else if i=5 then s:=s+inttostr(test[i]) else s:=s+inttostr(test[i])+'-'; end; showmessage(s); end;
比刚才的哪个简单点! var buf:array[0..5] of byte; s:String; i:integer; t:Tdatetime; begin buf[0]:=$03; buf[1]:=$06; buf[2]:=$0C; buf[3]:=$0E; buf[4]:=$28; buf[5]:=$10; t:=StrToDateTime(IntToStr(buf[0])+'-'+IntToStr(buf[1])+'-'+IntToStr(buf[2])+ ' '+IntToStr(buf[3])+':'+IntToStr(buf[4])+':'+IntToStr(buf[5])); ShowMessage(datetimetostr(t)); end;
截取-转化进制-转化string,应当很简单
var buf:array[0..5] of byte;
test:array[0..5] of integer;
i:integer;
s:string;
begin
buf[0]:=$03;
buf[1]:=$06;
buf[2]:=$0C;
buf[3]:=$0E;
buf[4]:=$28;
buf[5]:=$10;
for i:=0 to 5 do
begin
test[i]:=(buf[i]);
if (i=3) or (i=4) then
s:=s+inttostr(test[i])+':' else
if i=5 then
s:=s+inttostr(test[i]) else
s:=s+inttostr(test[i])+'-';
end;
showmessage(s);
end;
var buf:array[0..5] of byte;
s:String;
i:integer;
t:Tdatetime;
begin
buf[0]:=$03;
buf[1]:=$06;
buf[2]:=$0C;
buf[3]:=$0E;
buf[4]:=$28;
buf[5]:=$10;
t:=StrToDateTime(IntToStr(buf[0])+'-'+IntToStr(buf[1])+'-'+IntToStr(buf[2])+
' '+IntToStr(buf[3])+':'+IntToStr(buf[4])+':'+IntToStr(buf[5]));
ShowMessage(datetimetostr(t));
end;