Thema: Delphi Problem mit Countdown

Einzelnen Beitrag anzeigen

s-off
(Gast)

n/a Beiträge
 
#6

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:29
Probier's mal so

Delphi-Quellcode:
Procedure TForm1.Timer1Timer(Sender: TObject);
Var
   dtTargetDate: TDateTime;
   dtDiff: TDateTime;
Begin
   //Das Zieldatum
   dtTargetDate := StrToDateTime('03.08.2010 00:00:00');

   //Differenz zw. Zieldatum und jetzt
   dtDiff := dtTargetDate - Now;

   //Zeitelemente in den Labels darstellen
   lblJahre.Caption := Format('Noch %s Jahre,', [FormatDateTime('yy', dtDiff)]);
   lblTage.Caption := Format('%s Tage,', [FormatDateTime('dd', dtDiff)]);
   lblStunden.Caption := Format('%s Stunden,', [FormatDateTime('hh', dtDiff)]);
   lblMinuten.Caption := Format('%s Minuten,', [FormatDateTime('nn', dtDiff)]);
   lblSekunden.Caption := Format('und %s Sekunden bis zum %s', [FormatDateTime('ss', dtDiff), DateTimeToStr(dtTargetDate)]);
End;
  Mit Zitat antworten Zitat