Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

writing current date & time as file name using NSIS

Tags:

nsis

I developed an installer using NSIS. Every time I re-install the application, I want to create a backup of the existing database files.

How can I rename these database files using the following format 'currentdatetime'(ex: 201003101140 means 2010-03-10 at 11:40 AM)?

Thanks !

like image 737
vikaskardode Avatar asked Mar 09 '10 08:03

vikaskardode


1 Answers

There is a built-in function in NSIS for this called ${GetTime}

  !include "FileFunc.nsh"
  !insertmacro GetTime

  ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
  DetailPrint "currentdatetime=$2$1$0$4$5$6"

This will output something like

  currentdatetime=20130210205537

meaning "10-Feb-2013 20:55:37".

like image 61
Paul Jansen Avatar answered Oct 06 '22 00:10

Paul Jansen