Help Center/ Log Tank Service/ Best Practices/ Log Jobs (Beta)/ Processing Date and Time Using DSL Processing Functions/ Conversion Between Datetime Strings and Unix Timestamps
Updated on 2026-05-12 GMT+08:00
Conversion Between Datetime Strings and Unix Timestamps
- Processing functions
- Intelligent conversion function dt_str: converts a Unix timestamp, datetime object, or datetime string to a datetime string in a specified format.
- Dedicated function dt_strftimestamp: specifically converts a Unix timestamp to a datetime string.
- Intelligent conversion function dt_parsetimestamp: converts a datetime string or datetime object to a Unix timestamp.
- Scenario 1: converting a datetime string without a time zone to a Unix timestamp
To convert a datetime string without time zone information (for example, 2019-06-02 18:41:26) to a Unix timestamp, you must specify a time zone for the date and time. The resulting value will vary depending on the time zone provided.
- Raw log
{ "time": "2019-07-10 14:58:19" } - Processing rule
e_set("Shanghai_timestamp", dt_parsetimestamp(v("time"), tz="Asia/Shanghai")) e_set("Los_Angeles_timestamp", dt_parsetimestamp(v("time"), tz="America/Los_Angeles")) e_set("UTC_timestamp", dt_parsetimestamp(v("time"))) - Processing result
{ "time": "2019-07-10 14:58:19", "Shanghai_timestamp": 1562741899, "Los_Angeles_timestamp": 1562795899, "UTC_timestamp": 1562770699 }
- Raw log
- Scenario 2: converting a non-standard custom date format without a time zone to a Unix timestamp
- Raw log
{ "time1" : "2019-07-10 06:58:19", "time2": "2019/07/10 06-58-19" } - Processing rule
e_set("time3", dt_parsetimestamp(v("time1"))) e_set("time4", dt_parsetimestamp(dt_strptime(v("time2"), "%Y/%m/%d %H-%M-%S"))) - Processing result
{ "time1": "2019-07-10 06:58:19", "time2": "2019/07/10 06-58-19", "time3": 1562741899, "time4": 1562741899 }
- Raw log
Parent topic: Processing Date and Time Using DSL Processing Functions
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot