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

Torch Log Service

Copy page
Download PDF
expression function
Date value processing function
Copy page
Download PDF
Date value processing function
This topic describes the syntax and format of date value processing function, along with relevant usage examples.​
dt_str function​
A time processing function that converts date and time values to a time string in the specified time zone and format.​
Function syntax/format​
​
dt_str(value, fmt="target format", tz=None)​
​
The parameters are described below:​
​
Parameters​
Parameter type​
Required​
Default value​
Value range​
Description​
value​
String​
Yes​
/​
/​
Date and time value to be converted.​
fmt​
String​
No​
/​
/​
The format of the output date string.​
tz​
String​
No​
/​
Time zone list​
Target time zone for conversion. The default is None.​
​
Function examples​
  • Scenario: After converting the value of the time field in the log to a time, output it to the dt_str field in the format specified by the fmt field.​
  • Processing rules:​
  • ​
    f_set("dt_str", dt_str(v("time"), fmt=v("fmt")))​
    ​
  • Log example​
  • ​
    {​
    "time":"2022-12-26 13:03:21",​
    "fmt":"%Y/%m/%d %H-%M-%S"​
    }​
    ​
  • Processing result:​
  • ​
    {​
    "time":"2022-12-26 13:03:21",​
    "fmt":"%Y/%m/%d %H-%M-%S",​
    "dt_str":"2022/12/26 13-03-21"​
    }​
    ​
dt_to_timestamp function​
Convert time-type field values to UTC timestamps after adjusting them to the specified time zone.​
Function syntax/format​
​
dt_to_timestamp(value, tz=None)​
​
The parameters are described below:​
​
Parameters​
Parameter type​
Required​
Default value​
Value range​
Description​
value​
String​
Yes​
/​
/​
Value to be converted.​
tz​
String​
No​
/​
Time zone list​
Target time zone for conversion.​
​
Function examples​
  • Scenario: Convert the value of the time field in the log according to the time zone specified in the tz field, and then output the UTC timestamp.​
  • Processing rules:​
  • ​
    f_set("dt_to_timestamp", dt_to_timestamp(v("time"), v("tz")))​
    ​
  • Log example​
  • ​
    {​
    "time":"2022-12-26 13:03:21",​
    "tz":"Asia/Shanghai"​
    }​
    ​
  • Processing result:​
  • ​
    {​
    "time":"2022-12-26 13:03:21",​
    "tz":"Asia/Shanghai",​
    "dt_to_timestamp":1672031001​
    }​
    ​
dt_from_timestamp function​
After converting time-type timestamp fields into time values in the specified time zone, convert the timestamp fields into time strings.​
Function syntax/format​
​
dt_from_timestamp(value, tz=None)​
​
The parameters are described below:​
​
Parameters​
Parameter type​
Required​
Default value​
Value range​
Description​
value​
Number​
Yes​
/​
/​
Value to be converted.​
tz​
String​
No​
/​
Time zone list​
Target time zone for conversion.​
​
Function examples​
  • Scenario: Convert the value of the time field in logs to a time based on the time zone specified by the tz field, and then output the time as a string.​
  • Processing rules:​
  • ​
    f_set("dt_from_timestamp", dt_from_timestamp(v("time"), tz=v("tz")))​
    ​
  • Log example​
  • ​
    {​
    "time":"1672057815"​
    }​
    ​
  • Processing result:​
  • ​
    {​
    "time":"1672057815",​
    "dt_from_timestamp":"2022-12-26 20:30:15"​
    }​
    ​
dt_now function​
Get the local time during data transformation calculation.​
Function syntax/format​
​
dt_now(tz="")​
​
The parameters are described below:​
​
Parameters​
Parameter type​
Required​
Default value​
Value range​
Description​
tz​
String​
No​
/​
Time zone list​
Target time zone for conversion.​
​
Function examples​
  • Scenario: Obtain the local time during processing based on the timezone specified by the tz field in the log, and output it to the dt_now field.​
  • Processing rules:​
  • ​
    f_set("dt_now", dt_now(tz=v("tz")))​
    ​
  • Log example​
  • ​
    {​
    "tz":"Asia/Shanghai"​
    }​
    ​
  • Processing result:​
  • ​
    {​
    "tz":"Asia/Shanghai",​
    "dt_now":"2022-12-27 19:56:31.223646+08:00"​
    }​
    ​
​
Last updated: 2026.05.20 10:40:30