DateAndTime.Today Property

Definition

Returns or sets a Date value containing the current date according to your system.

C#
public static DateTime Today { get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
C#
public static DateTime Today { get; set; }

Property Value

Returns or sets a Date value containing the current date according to your system.

Attributes

Examples

This example uses the Today property to return the current system date.

VB
Dim thisDate As Date
thisDate = Today

Remarks

The Date data type includes time components. When returning the system date, Today sets all of these to 0, so the returned value represents midnight (00:00:00). When setting the system date, Today ignores the time components.

To access the current system date as a String, use the DateString property.

To get or set the current system time, use the TimeOfDay property.

Important

Setting the system date or time requires unmanaged code permission, which might affect its execution in partial-trust situations. For more information, see SecurityPermission and Code Access Permissions.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also