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 obtain 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. A time between 0:00:00 (12:00:00 A.M.) and 23:59:59 (11:59:59 P.M.), or any expression that can represent this range of time.

Example

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)) 'strings can also be accepted as long as they can be judged.

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