Skip to content
⌘ NSIS Forum Archive

Get Current Date

4 posts

rainwater#

Get Current Date

I saw a few posts regarding how to get the current date. So I wrote a extension dll to just that. The dll file lets you set a format string and it will return the date using that format string. I've attached the extension and source. See the readme.txt for info on the format string.

I'm also working on an extension to be able to get the same info on files.
Nutster#
My use of this add-on

This is excellent. I use this to manage the update system for software installations at my clients. I install a new version of the software on the client's server and the software running on the workstations checks the date of the new install vs. the date and time of the last install to see if things are out of date.
Bernybon#
I'm trying to do this:

Section "MyCommands"

SetOutPath "${BeamcutSoftPath}"
File "${BeamcutSoftPath}\Temp\nsisdt.dll"
StrCpy $0 "%Y.%m.%d-%H.%M.%S"
CallInstDLL "${BeamcutSoftPath}\nsisdt.dll" currentdate
MessageBox MB_OK "Date=$0"

Rename "${MyCommandsPath}" "${MyCommandsPath} Backup $0"
SetOutPath "${MyCommandsPath}"
File /R "My Commands\*.*"

SectionEnd​
but the value of $0 is always %Y.%m.%d-%H.%M.%S only, not the actual value needed
can you help me ?
Anders#
You just responded to a thread that is 20 years old! Things have slightly changed.

First of all, you need to add "Unicode False" to your .nsi to have any hope of it working. Beyond that, the new plug-in syntax is dll::function name. You can see that @ https://nsis.sourceforge.io/NSIS-Date_plug-in

There is also https://stackoverflow.com/questions/...me-using-nsis#

And asking Windows:
   System::Call 'KERNEL32::GetDateFormat(i0x409,i0,p0,t"yyyyMMdd",t.s,i${NSIS_MAX_STRLEN})'
Pop $0
DetailPrint $0​ 
(there is also GetTimeFormat but I'm typing this on a phone and can't code that example right now)