Time, Time$ (functions)

Syntax Time[$][()]
Description Returns the system time as a String or as a Date variant.
Comments The Time$ function returns a String contains the time in 24-hour time format, whereas Time returns a Date variant. To set the time, use the Time/Time$ statements.
Example This example returns the system time and displays it in a dialog box.
Const crlf = Chr$(13) + Chr$(10)
Sub Main()
  oldtime$ = Time
  msg1 = "Time was: " & oldtime$ & crlf
  Time = "10:30:54"
  msg1 = msg1 & "Time set to: " & Time & crlf
  Time = oldtime$
  msg1 = msg1 & "Time restored to: " & Time
  MsgBox msg1
End Sub
See Also Time, Time$ (statements); Date, Date$ (functions); Date, Date$ (statements); Now (function).