Autohotkey FormatTime返回今天的日期,而不是变量的实际日期

Autohotkey FormatTime返回今天的日期,而不是变量的实际日期,autohotkey,Autohotkey,我从正则表达式中提取时间戳。这将是原始格式:YYYYMMDD 文档中没有时间戳,这似乎是可以接受的。我试过了,也试过了 我只想将其转换为MMMDD,但是,它只是在我尝试过的所有内容中输出今天的日期。所以我肯定错过了一些重要的事情 regexmatch(file_name, "O) (202[0-9][0]?[1]?\d{1}\d{2})", diag_date) ; diag_date[1] in all my testing has been 20200831 msgbox

我从正则表达式中提取时间戳。这将是原始格式:
YYYYMMDD

文档中没有时间戳,这似乎是可以接受的。我试过了,也试过了

我只想将其转换为
MMMDD
,但是,它只是在我尝试过的所有内容中输出今天的日期。所以我肯定错过了一些重要的事情

regexmatch(file_name, "O) (202[0-9][0]?[1]?\d{1}\d{2})", diag_date)
; diag_date[1] in all my testing has been 20200831
msgbox % "Unformatted Date: " diag_date[1] 
FormatTime, diag_date, diag_date[1], MMMdd
msgbox % "Formatted Date: " diag_date

--简单测试--


即使匹配的日期是另一个日期(例如20200831),最后一个msgbox仍会继续返回今天的日期。

您没有在第二个参数上强制使用表达式。所以它只是解释你传递了一个无效的时间戳

unformatted := "20200831"
FormatTime, formatted, % unformatted, MMMdd
msgbox % formatted
unformatted := "20200831"
FormatTime, formatted, % unformatted, MMMdd
msgbox % formatted