How to display current date and time in Free Pascal

You can use Now function to retreive current date and time from computer.

Sample:


var
  MyTime: TDateTime;
begin
  MyTime:= Now;
  Writeln('Now it is: ' + DateTimeToStr(MyTime));
end.

Make sure you have included sysutils unit in uses clause.

You can use FormatDateTime function to format date and time:


  Writeln('Today is: ' + FormatDateTime('yyy-mm-dd hh:nn', MyTime));

Advertisement

2 thoughts on “How to display current date and time in Free Pascal

  1. naturally like your web-site however you have to check the spelling on quite a few of your posts.
    Many of them are rife with spelling issues and I find it very troublesome to tell
    the truth nevertheless I will certainly come back
    again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s