Now Property

   
Now Property

Class

Microsoft.VisualBasic.DateAndTime

Syntax

 Now(  ) 

Return Value

A Date containing the current system date and time

Description

Returns the current date and time based on the system setting

Rules at a Glance

  • The date returned by Now takes the Windows General Date format based on the locale settings of the local computer. The U.S. setting for General Date is mm/dd/yy hh:mm:ss .

  • The Now property is read-only.

Example

The following example returns the date 10 days from today:

 MsgBox(DateAdd(DateInterval.Day, 10, Now(  ))) 

Programming Tips and Gotchas

  • It is often overlooked that workstations in a modern Windows environment are at the mercy of the user ! If your application relies on an accurate date and time setting, you should consider including a line in the workstation's logon script to synchronize the time with one of the servers. Many so-called bugs have been traced to a workstation that has had its date or time incorrectly altered by the user. The following line of code, when added to the logon script of an Windows NT 4.0 machine, will synchronize the machine's clock with that of a server called NTSERV1 :

     net time \NTSERV1 /set 
  • The Now property is often used to generate timestamps. However, for short- term timing and intra-day timestamps, the Timer property, which returns the number of milliseconds elapsed since midnight, affords greater accuracy.

  • The Now property wraps the BCL's System.DateTime.Now shared property. As a result, calls to the System.DateTime.Now property offer a slight performance improvement (about 20%) over calls to the VB.NET Now property.

See Also

Today Property

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net