System.DateTime
The System.DateTime is the main .NET class for working with dates and times.
System.DateTime.Now
System.DateTime.UtcNow
Gets a DateTime object that is set to the current date and time expressed in the UTC (Coordinated Universal Time) format.
System.DateTime oDateTime;
oDateTime = System.DateTime.UtcNow;
System.Diagnostics.Debug.Print(oDateTime.ToString("T"));
// 8:19:43 PM
System.DateTime.Today
System.DateTime.Parse
This assumes that dates are in US date format "mm/dd/yyyy"
This converts a string representation to a DateTime object.
Dim sDateTimeString As String
System.DateTime.Parse(sDateTimeString)
System.DateTime.ParseExact
This converts a string representation to a DateTime object. The format of the string representation must match the specified format.
Dim sDateTimeString As String
ParseExact(sDateTimeString, "dd-mmmm", System.Globalization.CultureInfo.InvariantCulture)
System.DateTime.TryParse
Dim sDateTimeString As String
Dim objResult As System.DateTime
System.DateTime.TryParse(sDateTimeString, result)
This doesn't change the value of "result" if the date is in UK format "dd/mm/yyyy"
System.DateTime.TryParseExact
This converts a string representation to a DateTime object. The format of the string representation must match the specified format
Returns True or False based on whether the conversion is successful
Dim sDateTimeString As String
Dim supportedformats() As String
Dim objDateTime As System.DateTime
supportedformats = New String() {"yyyy-MM-dd", "MM/dd/yyyy"}
System.DateTime.TryParseExact(sDateTimeString, _
supportedformats, _
System.Globalization.CultureInfo.CurrentCulture, _
System.Globalization.DateTimeStyles.None, _
objDateTime)
System.DateTimeOffset
This is a structure that represents a point in time expressed as a date and time of day, relative to UTC.
Gets a DateTimeOffset object that is set to the current date and time expressed in the UTC (Coordinated Universal Time) format whose offset is zero.
System.DateTimeOffset oDateTimeOffset;
oDateTimeOffset = System.DateTimeOffset.UtcNow;
System.Diagnostics.Debug.Print(oDateTimeOffset.ToString("T"));
// 8:19:43 PM
Properties
| Date | Gets the date component of this instance. |
| Day | Gets the day of the month represented by this instance. |
| DayOfWeek | Gets the day of the week represented by this instance. |
| DatyOfYear | Gets the day of the year represented by this instance. |
| Hour | Gets the hour component of the date represented by this instance. |
| Millisecond | Gets the milliseconds component of the date represented by this instance. |
| Minute | Gets the minute component of the date represented by this instance. |
| Month | Gets the month component of the date represented by this instance. |
| Now | Gets a DateTime that is the current local date and time on this computer. |
| Second | Gets the seconds component of the date represented by this instance. |
| Ticks | Gets the number of ticks that represent the date and time of this instance. |
| TimeOfDay | Gets the time of day for this instance. This returns a TimeSpan object. |
| Today | Gets the current date. |
| UtcNow | Gets a DateTime that is the current local date and time on this computer expressed as the coordinated universal time (UTC). |
| Year | Gets the year component of the date represented by this instance. |
Methods
| Add | Adds the value of the specified TimeSpan to the value of this instance. |
| AddDays | Adds the specified number of days to the value of this instance. |
| AddHours | Adds the specified number of hours to the value of this instance. |
| AddMilliseconds | Adds the specified number of milliseconds to the value of this instance. |
| AddMinutes | Adds the specified number of minutes to the value of this instance. |
| AddMonths | Adds the specified number of months to the value of this instance. |
| AddSeconds | Adds the specified number of seconds to the value of this instance. |
| AddTicks | Adds the specified number of ticks to the value of this instance. |
| AddYears | Adds the specified number of years to the value of this instance. |
| Compare | Compares two instances of DateTime and returns an indication of their relative values. |
| CompareTo | Compares this instance to a specified object and returns an indication of their relative values. |
| DaysInMonth | Returns the number of days in the specified month of the specified year. |
| Equals | Overloaded. Overridden. Returns a value indicating whether an instance of DateTime is equal to a specified object. |
| FromFileTime | Returns a DateTime equivalent to the specified operating system file timestamp. Returns an unsigned 8-byte value representing the date and time as the number of 100-nanosecond intervals that have elapsed since 1/1/1601 12:00 AM. |
| FromOADate | Returns a DateTime equivalent to the specified OLE Automation Date. |
| GetDateTimeFormats | Overloaded. Converts the value of this instance to allthe string representations supported by the standard DateTime format specifiers. |
| GetHashCode | Overridden. Returns the hash code for this instance. |
| GetType | Gets the Type of the current instance. |
| GetTypeCode | Returns the TypeCode for value type DateTime. |
| IsLeapYear | Returns an indication whether the specified year is a leap year. |
| Parse | Overloaded. Converts the specified string representation of a date and time to its DateTime equivalent. |
| ParseExact | Overloaded. Converts the specified string representation of a date and time to its DateTime equivalent. The format of the string representation must match a specified format exactly. |
| Subtract | Overloaded. Subtracts the specified time or duration from this instance. |
| ToFileTime | Converts the value of this instance to the format of the local system file time. |
| ToLocalTime | Converts the current coordinated universal time (UTC) to local time. Consirders the DateTime value a UTC value as converts it to a local time. |
| ToLongDateString | Converts the value of this instance to its equivalent long date string representation. |
| ToLondTimeString | Converts the value of this instance to its equivalent long time string representation. |
| ToOADate | Converts the value of this instance to the equivalent OLE Automation date. Converts to an OLE Automation-compatible value. This is a double value similar to the Date values used in VB 6.0. |
| ToShortDateString | Converts the value of this instance to its equivalent short time string representation. |
| ToString | Overloaded. Overridden. Converts the value of this instance to its equivalent string representation. |
| ToUniversalTime | Converts the current local time to coordinated universal time (UTC). This considers the DateTime value to be a local time and converts it to Coordinated Universal Time (UTC). |
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext