VBScript TimeValue Function
Definition and Usage
The TimeValue function can return a variable of the date sub-type that contains time.
The TimeValue function can be used to extract the time part of the parameter.
Note:If the parameter does not contain time, TimeValue will return 0, and the output result will be 12:00:00 AM.
Syntax
TimeValue(time)
Parameter | Description |
---|---|
time | Required. Between 0:00:00 (12:00:00 A.M.) - 23:59:59 (11:59:59 P.M.) time, or any expression that can represent this range of time. |
Instance
Example 1
D = #7/1/96 13:30:00# document.write(TimeValue(D))
Output:
13:30:00 or 1:30:00 PM
Example 2
D = "7/1/96 13:30:00" document.write(TimeValue(D)) 'as long as it can be judged, string can also be accepted.
Output:
13:30:00 or 1:30:00 PM
Example 3
D = "7/1/96" document.write(TimeValue(D)) 'only date
Output:
12:00:00 AM 'equivalent to 0