Sample code for 30+ languages & platforms
Delphi DLL

Date/Time Expires Within N Seconds/Minutes/Hours/Days

Demonstrates the how to tell if a date/time is within N seconds, minutes, hours, or days of the current system time.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, CkDateTime;

...

procedure TForm1.Button1Click(Sender: TObject);
var
dt: HCkDateTime;
b: Boolean;

begin
dt := CkDateTime_Create();

// Set to the current system date/time.
CkDateTime_SetFromCurrentSystemTime(dt);
Memo1.Lines.Add('Now: ' + CkDateTime__getAsTimestamp(dt,True));

// Add 10 minutes, making the date 10 minutes in the future.
CkDateTime_AddSeconds(dt,600);
Memo1.Lines.Add('10 minutes from now: ' + CkDateTime__getAsTimestamp(dt,True));

// Is the date/time within 10 seconds of expiration (i.e. within 10 seconds of now)?
b := CkDateTime_ExpiresWithin(dt,10,'seconds');
Memo1.Lines.Add('Expires within 10 seconds: ' + IntToStr(Ord(b)));

// Does the date/time expire within 5 minutes?
b := CkDateTime_ExpiresWithin(dt,5,'minutes');
Memo1.Lines.Add('Expires within 5 minutes: ' + IntToStr(Ord(b)));

// Does the date/time expire within 15 minutes?
b := CkDateTime_ExpiresWithin(dt,15,'minutes');
Memo1.Lines.Add('Expires within 15 minutes: ' + IntToStr(Ord(b)));

// Does the date/time expire within 1 hour?
b := CkDateTime_ExpiresWithin(dt,1,'hour');
Memo1.Lines.Add('Expires within 1 hour: ' + IntToStr(Ord(b)));

// Does the date/time expire within 1 day?
b := CkDateTime_ExpiresWithin(dt,1,'day');
Memo1.Lines.Add('Expires within 1 day: ' + IntToStr(Ord(b)));

// Output:

// 	Now: 2017-05-05T23:48:00-0500
// 	10 minutes from now: 2017-05-05T23:58:00-0500
// 	Expires within 10 seconds: False
// 	Expires within 5 minutes: False
// 	Expires within 15 minutes: True
// 	Expires within 1 hour: True
// 	Expires within 1 day: True

CkDateTime_Dispose(dt);

end;