首页 > 解决方案 > 从 NSIS 中的时间戳获取日期

问题描述

我对NSIS很陌生,我试图从给定的时间戳中获取日期、小时、分钟等。

有什么办法吗?

提前感谢您的任何答案...

标签: datetimestampnsis

解决方案


!include LogicLib.nsh
Section
StrCpy $0 1568807339 ; UNIX time
System::Int64Op $0 * 10000000
System::Int64Op 116444736000000000 + ; support.microsoft.com/en-us/help/167296/how-to-convert-a-unix-time-t-to-a-win32-filetime-or-systemtime
System::Call 'KERNEL32::FileTimeToLocalFileTime(*ls,*l.s)' ; This line is optional, comment it out if you want to keep it UTC
System::Call 'KERNEL32::FileTimeToSystemTime(*ls,@r0)i.r1' ; NSIS v3+
${If} $1 <> 0
    System::Call '*$0(&i2.r1,&i2.r2,&i2,&i2.r3,&i2.r4,&i2.r5,&i2.r6)'
    IntFmt $2 "%.2d" $2
    IntFmt $3 "%.2d" $3
    IntFmt $4 "%.2d" $4
    IntFmt $5 "%.2d" $5
    IntFmt $6 "%.2d" $6
    DetailPrint "$1/$2/$3 $4:$5:$6"

    System::Call 'KERNEL32::GetDateFormat(i0x0400,i0,pr0,p0,t.r1,i666)'
    System::Call 'KERNEL32::GetTimeFormat(i0x0400,i0,pr0,p0,t.r2,i666)'
    DetailPrint "$1 $2"
${EndIf}
SectionEnd

推荐阅读