Date Time Formats
Trouble seeing the images? Right click on images and open in new tab to enlarge or zoom in on the page (Ctrl + mousewheel).
Article Goal: Cover the Date / Time format strings
In this article we are going to cover the available standard and custom Date / Time format strings.
Standard Format Strings for Date/Time Values
The Standard date / time format strings contain a single character. This character defines the pattern used to display the value (if and how to display the year, month, etc.).
Format Specifier |
Description |
Sample Output |
---|---|---|
d | Short date | 2/22/2023 |
D | Long date | Wednesday, February 22, 2023 |
t | Short time | 12:00 AM |
T | Long time | 12:00:00 AM |
f |
Full date/time (short time) |
Wednesday, February 22, 2023 12:00 AM |
F |
Full date/time (long time) |
Wednesday, February 22, 2023 12:00:00 AM |
g |
General date/time (short time) |
2/22/2023 12:00 AM |
G |
General date/time (long time) |
2/22/2023 12:00:00 AM |
Custom Format Strings for Date/Time Values
To create format patterns for date and time values, combine the strings listed in the tables below. These strings represent the year, month, day, hours, minutes, seconds, etc. in different formats.
The following table lists the most frequently used strings that can be used to format dates.
Format Specifier | Description | Sample Output (2/22/2023) |
yy | The last two digits of the year. | 23 |
yyyy | A four-digit year. | 2023 |
MM | The number of the month. | 02 |
MMM | A short text description of the month. | Feb |
MMMM | The full name of the month. | February |
dd | Day of the week (number) | 22 |
ddd | Day of the week (short name) | Wed |
dddd | Day of the week (full name) | Wednesday |
/ | Date separator; appearance depends on regional settings. | Wednesday / February / 22 / 2023 |
The next table lists strings that are used to format time values.
Format Specifier | Description |
---|---|
hh | Hours |
mm | Minutes |
ss | Seconds |
tt | If present, represents data in AM/PM format |
: | Time separator; appearance depends upon regional settings |
Comments
0 comments
Please sign in to leave a comment.