Help Center/ Log Tank Service/ Best Practices/ Log Jobs (Beta)/ Processing Date and Time Using DSL Processing Functions/ Conversion Between Datetime Objects and Datetime Strings
Updated on 2026-05-12 GMT+08:00
Conversion Between Datetime Objects and Datetime Strings
- Processing functions
- Intelligent conversion function dt_parse: converts a datetime string or Unix timestamp to a datetime object.
- dt_astimezone: returns a datetime object with new time zone information.
- Scenario 1: converting a datetime string without time zone information to a datetime object in a specified time zone.
For example, a datetime string like 2019-06-04 2:41:26 that lacks time zone information can be converted between different time zones by utilizing its Unix timestamp. In this case, convert a datetime from the Los Angeles time zone to the Shanghai time zone.
- Raw log: The value of the time field is Los Angeles time.
{ "time" : "2019-06-04 2:41:26" } - Processing rule
e_set("timestamp", dt_parsetimestamp(v("time"), tz="America/Los_Angeles")) e_set("Shanghai_time", dt_parse(v("timestamp"), tz="Asia/Shanghai")) - Processing result
{ "Shanghai_time": "2019-06-04 17:41:26+08:00", "time": "2019-06-04 2:41:26", "timestamp": 1559641286 }
- Raw log: The value of the time field is Los Angeles time.
- Scenario 2: converting a datetime string without a time zone to a datetime object with a time zone
- Raw log
{ "time" : "2019-07-10 06:58:19" } - Processing rule
e_set("new_time", dt_parse(v("time"), tz="Asia/Shanghai")) - Processing result
{ "new_time": "2019-07-10 06:58:19+08:00", "time": "2019-07-10 06:58:19" }
- Raw log
- Scenario 3: converting a datetime string with a time zone to a datetime object in the target time zone.
- Raw log
{ "time" : "2019-06-04 2:41:26+08:00" } - Processing rule
e_set("new_time",dt_astimezone(v("time"), "America/Los_Angeles")) - Processing result
{ "new_time": "2019-06-03 11:41:26-07:00", "time": "2019-06-04 2:41:26+08:00" }
- 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