Delphi countdown time

I Have 2 dates and times
                  hh mm ss    
07/11/2008 02.58.55 PM  from computer date time
09/11/2008 03.15.00 PM from manual input

I want to seup a count down showing the Hours Minutes and Seconds remaining
as the computer time changes

Is there an easy code to use
KevinfeeningAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodedKSenior Software EngineerCommented:
Hi Kevinfeening.

Check this out :
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21984259.html

procedure TForm1.Button1Click(Sender: TObject);

    function ReadTime(str:String):TDateTime;
    begin
       result:=EncodeDateTime
                              (StrToInt(Copy(str,1,2)),  // <- the day
                              StrToInt(Copy(str,4,2)),  // <- the month
                              StrToInt(Copy(str,7,4)),  // <- the year
                              StrToInt(Copy(str,12,2)), // <- hour
                              StrToInt(Copy(str,15,2)), // <-minutes
                              StrToInt(Copy(str,18,2)), // <-seconds
                              StrToInt(Copy(str,21,2)));
    end;

var
  s1,s2:String;
  dt1,dt2:TDateTime;
  secDif:LongInt;
  begin
  s1:='07/11/2008 02.58.55 PM';
  s2:='09/11/2008 03.15.00 PM';

  dt1:=ReadTime(s1);
  dt2:=ReadTime(s2);
  secDif:=SecondsBetween(dt1,dt2);

  ShowMessage('Diff. in seconds: '+IntToStr(secDif));

  ShowMessage('Diff: '+IntToStr(secDif div 3600)+' hours, '
              +IntToStr((secDif mod 3600) div 60)+' minutes, '
              +IntToStr((secDif mod 3600) mod 60)+' seconds');
end;

-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
If you put this code in a timer event (1 second interval) instead of a button and instead of ShowMessage if you pass it to a label then you have your answer.

Hope this helps.
0
CodedKSenior Software EngineerCommented:
I'm not very sure if i got the copy(from, to) right because i cant check it right now.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.