Predefined Date/Time Formats (Format Function)
The following table identifies the predefined date and time format names. These may be used by name as the style argument for the Format function:
Format Name |
Description |
---|---|
General Date, or G |
Displays a date and/or time. For example, 3/12/2008 11:07:31 AM. Date display is determined by your application's current culture value. |
Long Date, Medium Date, or D |
Displays a date according to your current culture's long date format. For example, Wednesday, March 12, 2008. |
Short Date, or d |
Displays a date using your current culture's short date format. For example, 3/12/2008. The d character displays the day in a user-defined date format. For more information, see User-Defined Date/Time Formats (Format Function). |
Long Time, Medium Time, or T |
Displays a time using your current culture's long time format; typically includes hours, minutes, seconds. For example, 11:07:31 AM. |
Short Time or t |
Displays a time using your current culture's short time format. For example, 11:07 AM. The t character displays AM or PM values for locales that use a 12-hour clock in a user-defined time format. For more information, see User-Defined Date/Time Formats (Format Function). |
f |
Displays the long date and short time according to your current culture's format. For example, Wednesday, March 12, 2008 11:07 AM. |
F |
Displays the long date and long time according to your current culture's format. For example, Wednesday, March 12, 2008 11:07:31 AM. |
g |
Displays the short date and short time according to your current culture's format. For example, 3/12/2008 11:07 AM. |
M, m |
Displays the month and the day of a date. For example, March 12. The M character displays the month in a user-defined date format. The m character displays the minutes in a user-defined time format. For more information, see User-Defined Date/Time Formats (Format Function). |
R, r |
Formats the date according to the RFC1123Pattern property. For example, Wed, 12 Mar 2008 11:07:31 GMT. The formatted date does not adjust the value of the date and time. You must adjust the Date/Time value to GMT before calling the Format function. |
s |
Formats the date and time as a sortable index. For example, 2008-03-12T11:07:31. The s character displays the seconds in a user-defined time format. For more information, see User-Defined Date/Time Formats (Format Function). |
u |
Formats the date and time as a GMT sortable index. For example, 2008-03-12 11:07:31Z. |
U |
Formats the date and time with the long date and long time as GMT. For example, Wednesday, March 12, 2008 6:07:31 PM. |
Y, y |
Formats the date as the year and month. For example, March, 2008. The Y and y characters display the year in a user-defined date format. For more information, see User-Defined Date/Time Formats (Format Function). |
For more information about the application's current culture information, see How Culture Affects Strings in Visual Basic.
Requirements
Namespace:Microsoft.VisualBasic
**Module:**Strings
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
See Also
Reference
Predefined Numeric Formats (Format Function)
User-Defined Date/Time Formats (Format Function)
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Updated descriptions, added examples, and added links to clarify various format options. |
Customer feedback. |