O'Reilly logo

VB.NET Core Classes in a Nutshell by Ted Neward, Budi Kurniawan

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

DateTime

Synopsis

This simple value type represents a moment in time from 12:00:00 A.M., 1/1/0001 C.E. (Common Era), to 11:59:59 P.M., 12/31/9999 C.E., which is measured to the nearest tick, or 100-nanosecond interval. You can use this type in greater-than/less-than comparisons, sorting, and in calculations using other DateTime or TimeSpan instances. You can also use convenient Add. . . methods, such as AddSeconds(), with a positive or negative value.

To extract part of a date, use properties such as Day and Minute. All properties except Ticks represent a single component of a compound date, not the whole date. You can convert a string into a DateTime using the shared Parse() or ParseExact() methods, which require that the date match the pattern specified by a supplied format string.

The DateTime class also provides valuable shared functions that can determine the number of days in a month (DaysInMonth()), evaluate whether a year is a leap year (IsLeapYear()), and retrieve the date stamp from a file (FromFileTime()). You can also get the current date from the shared property Today (or UtcNow for the coordinated universal time).

Public Structure DateTime : Implements IComparable, IFormattable, IConvertible
' Public Constructors
   Public Sub New(ByVal year As Integer, 
        ByVal month As Integer, ByVal day As Integer) 
   Public Sub New(ByVal year As Integer, 
        ByVal month As Integer, ByVal day As Integer, 
        ByVal calendar As System.Globalization.Calendar) 
   Public Sub New(ByVal year As Integer, ...

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