TimeValue函数将给定的输入字符串转换为有效时间。
TimeValue(StringTime)
<!DOCTYPE html> <html> <body> <script language = "vbscript" type = "text/vbscript"> document.write(TimeValue("20:30") & "<br />") document.write(TimeValue("5:15") & "<br />") document.write(TimeValue("2:30:58") & "<br />") </script> </body> </html>
将其另存为.html并在Internet Explorer中执行时,上述脚本将产生以下结果:
8:30:00 PM 5:15:00 AM 2:30:58 AM