anadem
21st March 2007 19:54 UTC
how to get the date and time?
Does NSIS have a way to get the current date and/or time? I want to create a file whose name includes the date plus time so other similar files doen't get overwritten. Or is there a "random" function so I can generate a unique name?
thanks
anadem
21st March 2007 20:21 UTC
Originally posted by Red Wine
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.6
Many thanks!
Oops -- I'm too ignorant to use this!
I added '!include "FileFunc.nsh"' (and the headerfile is being found ok) and copy-pasted the example code "${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6", but at compile time that's rejected with "Invalid command: ${GetTime}". (I tried both in a section by itself and in one of my sections.)
Is there magic sauce which I'm missing?
kichik
21st March 2007 21:18 UTC
To generate a random filename at runtime use GetTempFileName. To generate a random filename at compile time use !tempfile.
To generate a string including a date or time in compile time, use !define /date.
!define /date TIMESTAMP "%x %X"
Red Wine
21st March 2007 21:23 UTC
"Invalid command: ${GetTime}".
!include FileFunc.nsh
!insertmacro GetTime
anadem
21st March 2007 21:45 UTC
Originally posted by Red Wine
!include FileFunc.nsh
!insertmacro GetTime
Appreciated! It's good now, thanks, and i've learned a bit more!
anadem
21st March 2007 21:48 UTC
Originally posted by kichik
To generate a random filename at runtime use GetTempFileName. To generate a random filename at compile time use !tempfile.
To generate a string including a date or time in compile time, use !define /date.
!define /date TIMESTAMP "%x %X"
Thanks! useful! For now GetTime is what I need, but this gets me further up the learning-curve.
anadem
3rd April 2007 22:09 UTC
Hmm ... stuck again!
How is "${GetTime}" used in an uninstall section?
tia
Red Wine
3rd April 2007 22:19 UTC
!include FileFunc.nsh
!insertmacro un.GetTime
........
${un.GetTime}....
anadem
3rd April 2007 22:47 UTC
thanks again!