开发者

This code snippet isn't working as expected (VBScript)

        Dim value
        value = CDate(InputBox("Please enter the time (hh:mm)", "Time Input", FormatDateTime(Now, 4)))          
        ' validate the input here
        WScript.Echo value
        internal_Time = CDate(FormatDateTime(value, 4))
开发者_如何学编程

I am expecting the time to be as 08:24 or 13:12 but it's appearing as 8:26:12 AM


Here:

internal_Time = CDate(FormatDateTime(value, 4))

Your formatting to a string but then converting back to a Date, so the formatting is lost and the value is converted to a VB Date value that includes AM/PM, if its for display then just store the string:

internal_Time = FormatDateTime(value, 4)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜