【Delphi在一个范围内获取随机时间】

xiaoxiao2021-02-28  115

uses math; ... procedure TForm1.Button2Click(Sender: TObject); var d1,d2,r1,r2:double; a:tdatetime; d:tdatetime; begin d1:=encodedate(1999,1,1); d2:=encodedate(2000,1,1); randomize; r1:=random(floor(d2)-floor(d1)); randomize; r2:=random; d:=d1+r1+r2; edit1.Text:=formatdatetime('YYYY-MM-DD HH:NN:SS.zzz',d); ... procedure TForm1.Button2Click(Sender: TObject); var d1,d2,r1,r2:double; a:tdatetime; d:tdatetime; begin d1:=encodedate(1999,1,1); d2:=encodedate(2000,1,1); randomize; r1:=random(floor(d2)-floor(d1)); randomize; r2:=random; d:=d1+r1+r2; edit1.Text:=formatdatetime('YYYY-MM-DD HH:NN:SS.zzz',d); end;
转载请注明原文地址: https://www.6miu.com/read-66550.html

最新回复(0)