O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

Now Property

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required