FormatTime returns 今天的日期而不是变量的实际日期

FormatTime returns todays date instead of the actual date of the variable

我从正则表达式中提取时间戳。这将是原始格式: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

--更简单的测试--

unformatted := "20200831"
FormatTime, formatted, unformatted, MMMdd
msgbox % formatted
; still outputs today's date.

即使匹配的日期是另一个日期(例如 20200831),最后一个消息框仍然返回今天的日期

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

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