VBScript Hour Function



The Hour Function returns a number between 0 and 23 that represents the hour of the day for the specified time stamp.

Syntax

Hour(time) 

Example

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write("Line 1: " & Hour("3:13:45 PM") & "<br />")
         document.write("Line 2: " & Hour("23:13:45") & "<br />")
         document.write("Line 3: " & Hour("2:20 PM") & "<br />")
       
      </script>
   </body>
</html>

When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −

Line 1: 15
Line 2: 23
Line 3: 14 
vbscript_date.htm
Advertisements