问题好菜,怎么获取服务器上的系统时间(30分)

X

xp166

Unregistered / Unconfirmed
GUEST, unregistred user!
问题好菜,怎么获取服务器上的系统时间
 
net time //服务器名
net time //服务器名 /set :和服务器时间同步
 
Date aDate=new Date();
不过我们一般是取数据库时间作为系统时间。
 
我要把系统时间取出来,在插到库里去,怎么实现呢?
 
本地DELPHI需要知道远程服务器时间?
还是在服务器上执行DELPHI编写的程序?
 
SELECT Curent TimeStamp
 
Date aDate=new Date();
 
接受答案了.
 
做一个时间服务器:
1.server:D6的自带控件TimeServer
2.client:D6控件IdTime,配置IdTime
---------------------------
server的代码:
procedure TForm1.serverExecute(AThread: TIdPeerThread);
var
Present: TDateTime;
timestr,months,days,hours,mins,secs,msecs:string;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
DecodeTime(Present, Hour, Min, Sec, MSec);
//////
if month<10 then
months:='0'+inttostr(month) else
months:=inttostr(month);
if day<10 then
days:='0'+inttostr(day) else
days:=inttostr(day);
if hour<10 then
hours:='0'+inttostr(hour) else
hours:=inttostr(hour);
if min<10 then
mins:='0'+inttostr(min) else
mins:=inttostr(min);
if sec<10 then
secs:='0'+inttostr(sec) else
secs:=inttostr(sec);
if msec<100 then
begin
msecs:='0'+inttostr(msec);
if msec<10 then
msecs:='00'+inttostr(msec);
end
else
msecs:=inttostr(msec);
timestr :=IntToStr(Year)+Months+Days+Hours+Mins+secs+msecs;
with athread.Connectiondo
begin
WriteLn(timestr);
Disconnect ;
end;
end;

client:
用 time:=datetostr() 和time:=timetostr() 得到服务器的时间
搞定!
 
顶部