Answers for "VBScript ISO date format"

0

VBScript ISO date format

Public Function ToIsoDateTime(datetime) 
    ToIsoDateTime = ToIsoDate(datetime) & "T" & ToIsoTime(datetime) & CurrentTimezone
End Function

Public Function ToIsoDate(datetime)
    ToIsoDate = CStr(Year(datetime)) & "-" & StrN2(Month(datetime)) & "-" & StrN2(Day(datetime))
End Function    

Public Function ToIsoTime(datetime) 
    ToIsoTime = StrN2(Hour(datetime)) & ":" & StrN2(Minute(datetime)) & ":" & StrN2(Second(datetime))
End Function

Private Function StrN2(n)
    If Len(CStr(n)) < 2 Then StrN2 = "0" & n Else StrN2 = n
End Function
Posted by: Guest on May-06-2021

Browse Popular Code Answers by Language