VBS怎么将变量中的日期转换格式 比如将2017⼀3⼀19 转换为2017-03-19

2026年09月19日 20:12
有1个网友回答
网友(1):

s=FormatDate(Date, "yyyy-m-dd")
wsh.echo s

Function FormatDate(date_var, patrn)
    Dim RegExp, Match, Matches
    Set RegExp = New RegExp
    With RegExp
        .IgnoreCase = -1: .Global = -1
        FormatDate = patrn
        .pattern = "(yyyy|d|m)"
        For Each Match In .execute(patrn)
                FormatDate = Replace(FormatDate, Match, DatePart(Match, date_var))
        Next
    End With
End Function