VBScript Second Function

Definition and Usage

The Second function can return a number representing the seconds of the minute, ranging from 0 to 59.

Syntax

Second(time)
Parameter Description
time Required. Any expression that can represent time.

Example

Example 1

D = #1/15/2002 10:55:51 AM#
document.write(Second(D))

Output:

51

Example 2

T = #10:55:51 AM#
document.write(Second(T))

Output:

51

Example 3

The following example is an ASP function that can output Chinese-formatted time, which uses VBScript's Hour, Minute, and Second functions.

<%
Sub HHMMSS(T)
H = Hour(T)
If H<12 then
  Response.Write "AM" & H & " hours"
Else
  Response.Write "PM" & (H-12) & " hours"
End If
Response.Write Minute(T) & " minutes"
Response.Write Second(T) & " seconds"
End Sub
%>