12

Is there a way to get local date time stamp in Inno Setup ?

TLama
  • 75,147
  • 17
  • 214
  • 392

2 Answers2

24

The answer depends on when you need it.

  • Needed at the time the setup is built
  • Needed at the time of install.

Needed at the time the setup is built.

You will need to use ISPP which is part of the Quick Start pack.

You can use the str GetDateTimeString(str, str, str) function.

Example: #define MyDateTimeString GetDateTimeString('dd/mm/yyyy hh:nn:ss', '-', ':');

The help menu in ISTool (Also a part of the Quick Start Pack) has a good help file for ISPP functions including this one where there is a page of information on this function.

Needed at the time of install.

Although a different source, the function is also called GetDateTimeString Then it must be in a pascal coding block.

Example:

function DateTime : String;
begin
  result := GetDateTimeString('dd/mm/yyyy hh:nn:ss', '-', ':');
end;

The details of how to use it are found in the Help File.

Although both functions have the same name, the context of when they are used is important to understanding why you would get one value over another.

Robert Love
  • 12,447
  • 2
  • 48
  • 80
  • are you sure? `FormatDateTime` gives a compile error for me (I had to write my own). – rossmcm May 03 '11 at 07:21
  • I am now struggling to find out where I found this list. A simple scripting test, shows that TDateTime is not a supported type in InnoSetup Pascal Script. I will research options and update the answer. – Robert Love May 03 '11 at 13:28
  • The function needs a dummy string parameter, e.g. `function DateTime(dummy: String): String;` – SoftDeveloper May 29 '14 at 15:07
0

I updated your code:

function ActualDate(Param: string): String;
begin
   result := GetDateTimeString('dd/mm/yyyy hh:nn:ss', '-', ':');
end;