Name
TimeOfDay Property
Class
Microsoft.VisualBasic.DateAndTime
Syntax
TimeOfDay
Return Value
Date value giving the current system time
Description
Sets or returns the current system time
Example
The code:
TimeOfDay( ) = #9:05:13 AM#
sets the system time, and the code:
MsgBox(TimeOfDay( ))
displays the current system time.
Rules at a Glance
The TimeOfDay property returns the time in the time format defined by the system’s regional settings.
Programming Tips and Gotchas
The TimeOfDay property includes an incorrect date, 01/01/0001, along with the time. It can be eliminated with the Format or FormatDateTime function as follows:
Format(TimeOfDay( ), "Long Time") FormatDateTime(TimeOfDay( ), DateFormat.LongTime)
When setting the TimeOfDay property, any date component is ignored.
See Also
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.