Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save theilgaz/077931e492e645157a79ca7594414217 to your computer and use it in GitHub Desktop.
Save theilgaz/077931e492e645157a79ca7594414217 to your computer and use it in GitHub Desktop.
function GetCurrentDateTime:string;
var
Year, Month, Day, Hour, Min, Sec, MSec: Word;
sYear, sMonth, sDay, sHour, sMin, sSec: string;
begin
DecodeDate(Now, Year, Month, Day);
DecodeTime(Now, Hour, Min, Sec, MSec);
sYear := Copy(Year.ToString, 3, 2);
if Month < 10 then sMonth := '0'+Month.ToString else sMonth := Month.ToString;
if Day < 10 then sDay := '0'+Day.ToString else sDay := Day.ToString;
if Hour < 10 then sHour := '0'+Hour.ToString else sHour := Hour.ToString;
if Min < 10 then sMin := '0'+Min.ToString else sMin := Min.ToString;
if Sec < 10 then sSec := '0'+Sec.ToString else sSec := Sec.ToString;
//if MSec < 10 then sMSec := '0'+MSec.ToString else sMSec := MSec.ToString;
Result := sYear+sMonth+sDay+sHour+sMin+sSec;//+sMSec;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment