如何在 NSIS 中获取当前时间(当地时间)? [英] How do I get the current time (local time) in NSIS?

查看:90
本文介绍了如何在 NSIS 中获取当前时间(当地时间)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试为 NSIS 安装程序编写一些简单的日志记录到文件时,我很难找到获取当前时间的简单方法.

In trying to write some simple logging-to-file for an NSIS installer I had a lot of trouble finding a simple way of getting the current time.

没有内置函数,而且大多数第三方头文件或 DLL 看起来非常重量级,只是为了获取当前时间.

There are no built-in functions, and most of the third-party headers or DLLs seem awfully heavyweight for just getting the current time.

在 NSIS 脚本中获取当前时间的最直接方法是什么,最好不使用第三方库?

What's the most straightforward way to get the current time in an NSIS script, preferably without a third-party library?

(我已经用我可能会用的方式回答了这个问题,但如果有人有好的替代方案,请发布它们.)

(I've answered this with what I'm probably going with, but if anyone has good alternatives please post them.)

推荐答案

NSIS 附带的 FileFunc.nsh 头文件中似乎有一个函数.它主要用于获取文件创建/修改时间,但有一个本地时间选项:

It looks like there is a function in the FileFunc.nsh header that comes with NSIS. It's primarily for getting file creation/modification times, but has a localtime option:

; leave the first 'filename' parameter empty and specify "L" in the second to get the current time
${GetTime} "" "L" $day $month $year $day_name $hours $minutes $seconds

我不知道为什么在比 FileFunc.nsh 更常见的头文件中没有内置函数或标准 GetLocalTime

I'm not sure why ther isn't a built in function or a standard GetLocalTime in a more common header than FileFunc.nsh

这篇关于如何在 NSIS 中获取当前时间(当地时间)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆