The ANSI C standard defines a set of directives used to parse and format date and time strings.
Log Service supports all the directives defined in the ANSI C (1989 version) standard.
The following table describes these directives and provides specific examples and
notes.
Directive | Description | Example | Note |
---|---|---|---|
%a | The abbreviation of the weekday. | Mon, ..., Fri |
Currently, date and time strings are displayed in the en-US locale. Other locales are not supported. |
%A | The full name of the weekday. | Monday, ..., Friday |
Currently, date and time strings are displayed in the en-US locale. Other locales are not supported. |
%w | The weekday represented as a decimal number. 0 indicates Sunday, and 6 indicates Saturday. | 0, 1, 2, 3, 4, 5, 6 |
None. |
%d | The day of the month represented as a zero-padded decimal number. | 01, 02, ..., 31 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%b | The abbreviation of the month. | Jan, Feb, ..., Dec |
Currently, date and time strings are displayed in the en-US locale. Other locales are not supported. |
%B | The full name of the month. | January, February, ..., December |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%m | The month represented as a zero-padded decimal number. | 01, 02, ..., 12 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%y | The year without the century part, represented as a zero-padded decimal number. | 00, 01, ..., 99 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%Y | The year with the century part, represented as a zero-padded decimal number. | 0001, 0002, ..., 2013, 2014, ..., 9998, 9999 |
A year can be parsed from a number that ranges from 1 to 9999. If the year is earlier than 1000, it must be zero-filled to 4-digit width. For example, 0180 indicates the year of 180 AD. |
%H | The hour in the 24-hour format, represented as a zero-padded decimal number. | 00, 01, ..., 23 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%I | The hour in the 12-hour format, represented as a zero-padded decimal number. | 01, 02, ..., 12 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%p | The period in the 12-hour format. | AM, PM |
|
%M | The minute represented as a zero-padded decimal number. | 00, 01, ..., 59 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %j, %U, %W, %V, %y when they are used to parse date and time strings.
|
%S | The second represented as a zero-padded decimal number. | 00, 01, ..., 59 |
|
%f | The microsecond represented as a zero-padded decimal number. | 000000, 000001, ..., 999999 |
The %f directive can be used to parse the microsecond from a numeric string consisting of
0 to 6 characters.
|
%z | The UTC offset in the ±HHMM[SS[.ffffff]] format. An empty string is generated for this directive during parsing if the date and time string does not contain the time zone information. | (empty), +0000, -0400, +1030, +063415, -030712.345216 |
The %z and %Z directives are replaced by empty strings during parsing if the date and time string
does not contain the time zone information. The minute information is optional in
the string to be parsed by the %z directive to the±HHMM[SS[.ffffff]] format. Strings separated by colons (:) are supported during parsing. For example,
+01:00:00 is parsed as an offset of one hour. In addition, Z is identical to +00:00 .
|
%Z | The name of the time zone. An empty string is generated for this directive during parsing if the date and time string does not contain the time zone information. | (empty), UTC, EST, CST |
None. |
%j | The day of the year. | 001, 002, ..., 366 |
The leading zero is optional for formatting directives %d, %m, %H, %I, %M, %S, %J, %U, %W, %V, %y when they are used to parse date and time strings.
|
%U | The week number of the year, where Sunday is the first day of a week. A day before the first Sunday of the year is regarded as a day in week 0. | 00, 01, ..., 53 |
|
%W | The week number of the year, where Monday is the first day of a week. A day before the first Monday of the year is regarded as a day in week 0. | 00, 01, ..., 53 |
|
%c | The date and time representation in the current locale. | Tue Aug 16 21:30:00 1988 |
Currently, date and time strings are displayed in the en-US locale. Other locales are not supported. |
%x | The date representation in the current locale. | 08/16/88 |
Currently, date and time strings are displayed in the en-US locale. Other locales are not supported. |
%X | The time representation in the current locale. | 21:30:00 |
Currently, date and time strings are displayed in the en-US locale. Other locales are not supported. |
%% | The literal % character.
|
% |
None. |
Several additional directives not defined in the C (1989 version) standard are included
for convenience.
Directive | Description | Example | Note |
---|---|---|---|
%G | The ISO 8601 week-based year. | 0001, 0002, ..., 2013, 2014, ..., 9998, 9999 |
When used to parse data and time strings, the values obtained through the %V directive can only be used in calculation.
|
%u | The ISO 8601 weekday, where Monday is the first day of a week. | 1, 2, ..., 7 |
None. |
%V | The ISO 8601 week number, where Monday is the first day of a week. | 01, 02, ..., 53 |
|