Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v9.5.0.94+

Extract Timestamp from ULID

See more ULID/UUID Examples

Extract the date/time from a ULID.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
ulid: PWideChar;
dt: HCkDateTime;
bLocal: Boolean;

begin
success := False;

ulid := '01GRH14AA82EY9A7S99YYF2QDY';

dt := CkDateTime_Create();

//  Unix timestamps stored in ULIDs should be UTC...
bLocal := False;
//  Set the CkDateTime from the timestamp contained in the ULID
success := CkDateTime_SetFromUlid(dt,bLocal,ulid);
if (success = False) then
  begin
    Memo1.Lines.Add('ULID was not valid.');
    Exit;
  end;

//  You can now get the date/time in any desired format.
//  For example:
Memo1.Lines.Add('Unix timestamp = ' + IntToStr(CkDateTime_GetAsUnixTime(dt,bLocal)));
Memo1.Lines.Add('RFC822 = ' + CkDateTime__getAsRfc822(dt,bLocal));
Memo1.Lines.Add('Timestamp = ' + CkDateTime__getAsTimestamp(dt,bLocal));

//  Sample output:

//  Unix timestamp = 1675608861
//  RFC822 = Sun, 05 Feb 2023 14:54:21 GMT
//  Timestamp = 2023-02-05T14:54:21Z

CkDateTime_Dispose(dt);