This documentation is archived and is not being maintained.

DateAndTime.DateString Property

Returns or sets a String value representing the current date according to your system.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static string DateString { get; set; }

Property Value

Type: System.String
Returns or sets a String value representing the current date according to your system.

For more detailed information, see the Visual Basic topic DateString Property.

DateString returns the system date in the MM-dd-yyyy format, which uses the abbreviated month name. The accepted formats for the date are M-d-yyyy, M-d-y, M/d/yyyy, and M/d/y. This is true for all system locales except those that use a double-byte character set (DBCS). If the system locale uses a double-byte character set, DateString returns the system date in the yyyy-MM-dd format. The system locale is set by using the Clock, Language, and Region item in Control Panel.

NoteNote:

The DateString property returns the system date only in the yyyy-MM-dd format for the zh (Chinese simplified), ko (Korean), and ja (Japanese) system locales if you are running Visual Basic within Silverlight.

To get or set the current system time as a String, use the TimeString Property.

To get the current system date or time in the format of your locale, or in a custom format, supply the Now Property to the Format Function, specifying either Predefined Date/Time Formats (Format Function) or User-Defined Date/Time Formats (Format Function). The following example demonstrates this.

MsgBox("The formatted date is " & Format(Now, "dddd, d MMM yyyy"))

To access the current system date as a Date, use the Today Property.

Security noteSecurity Note:

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.

The following example uses the DateString property to display the current system date.

MsgBox("The current date is " & DateString)

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Show: