You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
general reference
Time format
Copy page
Download PDF
Time format
Log entries usually include a timestamp. When collecting log data with LogCollector, you can set a time conversion format. With this format, LogCollector can parse the embedded log timestamp as the log event time. This topic describes common time conversion formats and provides corresponding examples.​
Log timestamp​
When collecting log data via LogCollector, you can specify the log timestamp using either of the following methods.​
  • Use the log collection timestamp​
  • The collection system time recorded by LogCollector is used as the log timestamp. If LogCollector runs on a Linux server, the system time zone (time.Local) refers to the host time zone. If LogCollector runs in a K8s cluster, for LogCollector v2.0.0 and later version, the system time zone (time.Local) is UTC+08:00.​
  • Custom log time​
  • Extracts the timestamp embedded in the original log as the log timestamp. In this case, you need to enter the Time key name, Time regular (optional), Time conversion format, and Time zone attribute. When LogCollector collects log data, it parses the embedded timestamp in the original log based on your configured time conversion format and unifies the time as a unix timestamp.​
Notice​
  • If the time conversion format is incorrect, LogCollector can not parse the embedded timestamp in the original log. The log collection time will be used instead.​
  • By default, log time supports millisecond precision. If you need nanosecond accuracy, you can select Enable nanosecond time accuracy If milliseconds or nanoseconds are not specified in the Time conversion format, their values will automatically be set to 0.​
  • If the time recorded in the original log includes a time zone, you can specify a time zone parsing expression in the Time conversion format or configure a time zone attribute in the collection rule. The priority order is as follows:​
  • If a time zone expression (%z or %Z) is set in the Time conversion format and a time zone attribute is set in the collection rule, the time zone in the time conversion format (%z or %Z) will apply.​
  • If a time zone expression (%z or %Z) is set in the Time conversion format but no time zone attribute is specified in the collection rule, the time zone in the time conversion format (%z or %Z) will apply.​
  • If no time zone expression (%z or %Z) is set in the Time conversion format but a time zone attribute is set in the collection rule, the time zone set in the collection rule will apply.​
  • If no time zone expression (%z or %Z) is set in the Time conversion format and no time zone attribute is set in the collection rule, the system time zone (time.Local) will apply.​
  • If the log timestamp is more precise(longer) than the time conversion format you set, the extra precision in timestamp will be ignored. For example, if the log timestamp is 2024-04-30T16:33:31.399+0800 and the time conversion format is %Y-%m-%dT%H:%M:%S, then .399+0800 will be ignored and the final time result will be 2024-04-30 16:33:31.​
Common time conversion formats​
​
Category​
Time conversion format​
Description​
Example​
Century​
%C​
The number of centuries. It is calculated by dividing the year by 100; ranges from 00 to 99.​
01​
Year​
%Y​
The number of years (centuries are included). It ranges from 0000 to 9999. For example, 2022 represents the year 2022.​
2022​
​
%y​
The number of years (centuries are not included). It ranges from 00 to 99. For example, 22 represents the year 2022.​
22​
​
%G​
The number of years (centuries are included). It ranges from 0000 to 9999. For example, 2022 represents the year 2022.​
2022​
​
%g​
The number of years (centuries are not included). It ranges from 00 to 99. For example, 22 represents the year 2022.​
22​
Month​
%m​
The number of months; ranges from 01 to 12. For example, 02 means February.​
08​
​
%B​
Full month name in English.​
June​
​
%b​
Abbreviation of month name in English.​
Jan​
​
%h​
Abbreviation of month name in English, same as %b.​
Jan​
Day​
%d​
The number of dates. It ranges from 01 to 31. For example, 21 represents the 21st day of the month.​
21​
​
%e​
The number of dates. It ranges from 01 to 31. For example, 21 represents the 21st day of the month.​
Notice​
A space is needed before a single-digit number.​
21​
Hour​
%H​
The number of hours, 24-hour format; ranges from 00 to 23. For example, 21 represents 21 o'clock.​
21​
​
%I​
The number of hours, 12-hour format; ranges from 01 to 12. For example, 09 represents 9 o'clock.​
Note that I is the uppercase of i.​
09​
​
%P​
AM or PM.​
AM​
​
%p​
AM or PM.​
AM​
Minute​
%M​
The number of minutes; ranges from 00 to 59. For example, 01 represents one minute.​
01​
Second​
%S​
The number of seconds; ranges from 00 to 59. For example, 01 means 1 second.​
01​
Millisecond, microsecond, nanosecond.​
%f​
Millisecond, microsecond, nanosecond time. Ranges from 000000000 to 999999999. For example, 1 represents 100000000 nanoseconds.​
Notice​
If the digit number is less than 9, add zeros at the end.​
100000000​
Second-level timestamp​
%s​
Second-level unix timestamp; 10 digits.​
1651648193​
Millisecond-level timestamp​
%F​
Millisecond-level unix timestamp; 13 digits.​
1651648192000​
Time zone​
%Z​
Time zone name, such as UTC, EST, CST.​
UTC​
​
%z​
Time zone offset in ±HHMM format or ±HH:MM format. For example, +08:00 represents UTC+8 and -0500 represents UTC-5.​
-0500​
Others​
%A​
Full spelling of day name in a week.​
Thursday​
​
%a​
Abbreviation of day name in a week.​
Thur​
​
%j​
The ordinal number of days in a year; ranges from 001 to 366.​
340​
​
%%​
The % character.​
%​
​
Examples of time conversion formats​
​
Timestamp​
Time conversion format​
[2022-05-04 15:12:12.012]​
[%Y-%m-%d %H:%M:%S.%f]​
2019-10-12T07:20:50.52+07:00​
%Y-%m-%dT%H:%M:%S.%f%z​
2019-10-12T07:20:50.52+07:00​
%Y-%m-%dT%H:%M:%S.%f​
1651648409​
%s​
1651648416882​
%F​
​
​
Last updated: 2025.12.08 16:47:06