cls_convert_time
Convert between human-readable time expressions and Unix timestamps for CLS log and metric queries. Supports absolute dates, relative times, and timezone adjustments to ensure accurate timestamp parameters.
Instructions
时间与时间戳转换工具。在调用需要时间戳参数的 CLS 工具前,请先使用此工具进行精确转换,避免手动计算时间戳出错。
功能
可读时间 → 时间戳:传入 human_readable 参数,返回对应的 Unix 毫秒时间戳和秒级时间戳
时间戳 → 可读时间:传入 timestamp 参数(毫秒级),返回对应的可读时间字符串
同时返回毫秒和秒级时间戳,方便直接用于日志查询(毫秒)或指标查询(秒)
参数说明
timestamp: Unix 毫秒时间戳(整数),与 human_readable 二选一
human_readable: 人类可读时间表达式(字符串),与 timestamp 二选一,支持以下格式:
绝对时间:
2026-03-25 14:30:00、2026-03-25 14:30:00.123、2026-03-25 14:30、2026-03-25相对时间:
now、today、yesterday、tomorrow组合格式:
yesterday 12:00:00、today 09:30、tomorrow 08:00相对偏移:
3 hours ago、1 day ago、30 minutes ago、2 weeks ago
timezone: 时区名称,默认
Asia/Shanghai
使用示例
查询昨天12:00到13:00: 分别调用
human_readable="yesterday 12:00:00"和human_readable="yesterday 13:00:00"查询最近1小时: 调用
human_readable="1 hour ago"获取 start_time,human_readable="now"获取 end_time转换时间戳: 调用
timestamp=1774396800000查看对应的可读时间
返回格式
返回包含毫秒时间戳(用于 cls_search_log 等)、秒级时间戳(用于 cls_query_metric 等)和可读时间字符串。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timestamp | No | ||
| human_readable | No | ||
| timezone_name | No | Asia/Shanghai |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |