Looking for simple, direct examples of what the various DateTime conversion functions do which
MSDN was completely incapable of providing. Found a
great tutorial article that summarized them nicely:
result = theDate.ToString("y"); // result = "January 2007"
| Specifier | Description | Example |
|---|
| d | Short date format. This is equivalent to using ToShortDateString. | "03/01/2007" |
| D | Long date format. This is equivalent to using ToLongDateString. | "03 January 2007" |
| f | Date and time using long date and short time format. | "03 January 2007 21:25" |
| F | Date and time using long date and time format. | "03 January 2007 21:25:30" |
| g | Date and time using short date and time format. | "03/01/2007 21:25" |
| G | Date and time using short date and long time format. | "03/01/2007 21:25:30" |
| m | Day and month only. | "03 January" |
| r | Date and time in standard Greenwich Mean Time (GMT) format. | "Wed, 03 Jan 2007 21:25:30 GMT" |
| s | Sortable date and time format. The date elements start at the highest magnitude (year) and reduce along the string to the smallest magnitude (seconds). | "2007-01-03T21:25:30" |
| t | Short time format. This is equivalent to using ToShortTimeString. | "21:25" |
| T | Long time format. This is equivalent to using ToLongTimeString. | "21:25:30" |
| u | Short format, sortable co-ordinated universal time. | "2007-01-03 21:25:30Z" |
| U | Long format date and time. | "03 January 2007 17:25:30" |
| y | Month and year only. | "January 2007" |