日期与时间

OpenClaw 默认使用主机本地时间作为传输时间戳用户时区仅出现在系统提示词中。 提供商的时间戳原样保留,工具保持其原生语义(当前时间可通过 session_status 获取)。

消息信封(默认使用本地时间)

入站消息会被包裹上一个时间戳(精确到分钟):

[Provider ... 2026-01-05 16:26 PST] message text

这个信封时间戳默认使用主机本地时间,与提供商时区无关。

你可以覆盖这个行为:

{
  agents: {
    defaults: {
      envelopeTimezone: "local", // "utc" | "local" | "user" | IANA 时区
      envelopeTimestamp: "on", // "on" | "off"
      envelopeElapsed: "on", // "on" | "off"
    },
  },
}
  • envelopeTimezone: "utc" 使用 UTC。
  • envelopeTimezone: "local" 使用主机时区。
  • envelopeTimezone: "user" 使用 agents.defaults.userTimezone(如未设置则回退到主机时区)。
  • 使用显式的 IANA 时区(如 "America/Chicago")可以固定时区。
  • envelopeTimestamp: "off" 从信封头中移除绝对时间戳。
  • envelopeElapsed: "off" 移除已过时间后缀(即 +2m 风格的标记)。

示例

本地时间(默认):

[WhatsApp +1555 2026-01-18 00:19 PST] hello

用户时区:

[WhatsApp +1555 2026-01-18 00:19 CST] hello

启用已过时间:

[WhatsApp +1555 +30s 2026-01-18T05:19Z] follow-up

系统提示词:当前日期与时间

如果已知用户时区,系统提示词会包含一个专门的 Current Date & Time 部分,其中只有时区信息(不含时钟/时间格式),以保持提示词缓存的稳定性:

Time zone: America/Chicago

当 agent 需要获取当前时间时,使用 session_status 工具;status card 中包含一行时间戳。

系统事件行(默认使用本地时间)

插入到 agent 上下文中的排队系统事件会加上时间戳前缀,时区选择规则与消息信封相同(默认:主机本地时间)。

System: [2026-01-12 12:19:17 PST] Model switched.

配置用户时区和格式

{
  agents: {
    defaults: {
      userTimezone: "America/Chicago",
      timeFormat: "auto", // auto | 12 | 24
    },
  },
}
  • userTimezone 设置提示词上下文中的用户本地时区
  • timeFormat 控制提示词中的 12/24 小时制auto 跟随操作系统偏好。

时间格式检测(auto)

timeFormat: "auto" 时,OpenClaw 会检查操作系统偏好(macOS/Windows),如果获取不到则回退到区域格式。检测结果按进程缓存,避免重复调用系统接口。

工具载荷与连接器(原始提供商时间 + 规范化字段)

渠道工具返回提供商原生时间戳,并附加规范化字段以保持一致性:

  • timestampMs:UTC epoch 毫秒
  • timestampUtc:ISO 8601 UTC 字符串

原始提供商字段原样保留,不丢失任何信息。

  • Slack:API 返回的类 epoch 字符串
  • Discord:UTC ISO 时间戳
  • Telegram/WhatsApp:提供商特定的数字/ISO 时间戳

如果需要本地时间,利用已知时区在下游自行转换。

相关文档