Old 21st March 2007, 17:54   #1
anadem
Junior Member
 
Join Date: Mar 2007
Posts: 12
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 is offline   Reply With Quote
Old 21st March 2007, 18:00   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.6

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 21st March 2007, 18:21   #3
anadem
Junior Member
 
Join Date: Mar 2007
Posts: 12
Unhappy

Quote:
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?

Last edited by anadem; 21st March 2007 at 18:59.
anadem is offline   Reply With Quote
Old 21st March 2007, 19:18   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.
code:
!define /date TIMESTAMP "%x %X"

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 21st March 2007, 19:23   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
"Invalid command: ${GetTime}".
!include FileFunc.nsh
!insertmacro GetTime

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 21st March 2007, 19:45   #6
anadem
Junior Member
 
Join Date: Mar 2007
Posts: 12
Thumbs up

Quote:
Originally posted by Red Wine
!include FileFunc.nsh
!insertmacro GetTime
Appreciated! It's good now, thanks, and i've learned a bit more!
anadem is offline   Reply With Quote
Old 21st March 2007, 19:48   #7
anadem
Junior Member
 
Join Date: Mar 2007
Posts: 12
Quote:
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.
code:
!define /date TIMESTAMP "%x %X"
Thanks! useful! For now GetTime is what I need, but this gets me further up the learning-curve.
anadem is offline   Reply With Quote
Old 3rd April 2007, 21:09   #8
anadem
Junior Member
 
Join Date: Mar 2007
Posts: 12
Hmm ... stuck again!

How is "${GetTime}" used in an uninstall section?

tia
anadem is offline   Reply With Quote
Old 3rd April 2007, 21:19   #9
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
!include FileFunc.nsh
!insertmacro un.GetTime
........
${un.GetTime}....

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 3rd April 2007, 21:47   #10
anadem
Junior Member
 
Join Date: Mar 2007
Posts: 12
thanks again!
anadem is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump