C-Extensions / Formatting directives |
A datetime formatting mask specifies a format to apply to some datetime value. This mask is a combination of the following formatting directives:
Directive | Description |
---|---|
%a | Identifies abbreviated weekday name as defined in locale. |
%A | Identifies full weekday name as defined in locale. |
%b | Identifies abbreviated month name as defined in locale. |
%B | Identifies full month name as defined in locale. |
%C | Identifies century number (year divided by 100 and truncated to an integer) |
%d | Identifies the day of the month (01 to 31). Single digit is preceded by zero. |
%D | Identifies commonly used date format (%m/%d/%y). |
%e | Identifies the day of the month as a number (1 to 31). Single digit is preceded by space. |
%h | Same as %b. |
%iy | Identifies the year as a 2-digit number (00 to 99). |
%iY | Identifies the year as a 4-digit number (0000 to 9999). |
%m | Identifies the month as a number (01 to 12). Single digit is preceded by zero. |
%w | Identifies the weekday as a number (0 to 6), where 0 is the locale equivalent of Sunday. |
%x | Identifies a special date representation that the locale defines. |
%y | Identifies the year as a 2-digit number (00 to 99). |
%Y | Identifies the year as a 4-digit number (0000 to 9999). |
Directive | Description |
---|---|
%c | Identifies special date/time representation that locale defines. |
%Fn | Identifies value of the fraction of a second, with precision specified by integer n. Range of n is 0 to 5. The %Fn directive includes the dot character: For example, if you want to specify a format a time value as 23:35:17.9123, you must use %H:%M:%S%F4 |
%H | Identifies the hour as 24-hour clock integer (00-23). |
%I | Identifies the hour as 12-hour clock integer (00-12). |
%M | Identifies the minute as an integer (00-59). |
%p | Identifies AM or PM equivalent as defined in locale. |
%r | Identifies commonly used time representation for a 12-hour clock. |
%R | Identifies commonly used time representation for a 24-hour clock (%H:%M). |
%S | Identifies the second as an integer (00-61). Second can be up to 61 instead of 59 to allow for the occasional leap second and double leap second. |
%T | Identifies commonly used time format (%H:%M:%S). |
%X | Identifies commonly used time representation as defined in the locale. |
Directive | Description |
---|---|
%% | Identifies the % character. |
%n | Identifies a newline character. |
%t | Identifies a TAB character. |
Any other characters in the formatting mask are reproduced literally in the result.