How to get the current date and time in Pascal

1 Answer

0 votes
program GetCurrentDateTime;

uses
  SysUtils;

var
  currentDateTime: TDateTime;
  formattedDateTime: string;

begin
  currentDateTime := Now;
  
  formattedDateTime := FormatDateTime('yyyy-mm-dd hh:nn:ss', currentDateTime);
  
  WriteLn('Current date and time: ', formattedDateTime);
end.



(*
run:

Current date and time: 2025-05-05 19:38:12

*)  

 



answered May 5, 2025 by avibootz
...