DelphiDabbler Code Snippets Database

Snippet Selection

The following snippets from the Code Snippets Database have been requested.

NowGMT

Returns the current date and time converted to UTC/GMT.

function NowGMT: TDateTime;
var
  ST: Windows.TSystemTime;  // current system time
begin
  // This Windows API function gets system time in UTC/GMT
  Windows.GetSystemTime(ST);
  Result := SysUtils.SystemTimeToDateTime(ST);
end;

RFC1123DateGMT

Returns the given date time value, which must be in GMT/UTC, as a RFC1123 formatted string.

function RFC1123DateGMT(const DT: TDateTime): string;
const
  RFC1123Pattern = 'ddd, dd mmm yyyy HH'':''nn'':''ss ''GMT''';
begin
  Result := SysUtils.FormatDateTime(RFC1123Pattern, DT);
end;

View the whole database.

Go to the DelphiDabbler website.