openclaw - 💡(How to fix) Fix Bug: conversation-logger timestamp timezone error - local time incorrectly marked as UTC [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74991Fetched 2026-05-01 05:39:13
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
2
Timeline (top)
mentioned ×2subscribed ×2closed ×1commented ×1

Code Example

{
  "timestamp": "2026-04-30T16:22:06.430Z",
  "date": "2026-04-30"
}

---

$ node -e "console.log(new Date().toISOString())"
2026-04-30T08:29:16.247Z  # 正确的 UTC 时间

---

$ date
Thu Apr 30 16:29:31 CST 2026  # 北京时间
$ date -u
Thu Apr 30 08:29:31 UTC 2026  # UTC 时间

---

def parse_timestamp(ts: str) -> datetime | None:
    dt = datetime.fromisoformat(ts.replace("Z", ""))
    if ts.endswith("Z"):
        dt_as_utc = dt + timedelta(hours=8)
        if dt_as_utc > datetime.now() + timedelta(hours=1):
            # 时区标记错误,直接使用原始时间
            return dt
        else:
            return dt_as_utc
    return dt

---

{
  "agents": {
    "defaults": {
      "envelopeTimezone": "local",
      "userTimezone": "Asia/Shanghai"
    }
  },
  "hooks": {
    "internal": {
      "entries": {
        "conversation-logger": {
          "enabled": true
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Bug: conversation-logger 内部钩子时间戳时区错误

问题描述

OpenClaw Gateway 的 conversation-logger 内部钩子在写入 conversations.jsonl 时,时间戳被错误标记为 UTC,但实际内容是本地时间。

环境信息

  • OpenClaw 版本: 2026.4.22 (00bd2cf)
  • 系统: WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2)
  • 时区: Asia/Shanghai (UTC+8)
  • Node.js: v22.22.1

复现步骤

  1. 配置 userTimezone: "Asia/Shanghai"envelopeTimezone: "local"
  2. 启用 conversation-logger 内部钩子
  3. 发送消息,查看 memory/raw/YYYY-MM-DD-conversations.jsonl

实际行为

当前北京时间 16:22,JSONL 记录:

{
  "timestamp": "2026-04-30T16:22:06.430Z",
  "date": "2026-04-30"
}

时间戳被标记为 16:22Z(UTC),但实际应该是 08:22Z(UTC)。

预期行为

时间戳应为 2026-04-30T08:22:06.430Z(正确的 UTC 时间)。

验证

Node.js 行为正确:

$ node -e "console.log(new Date().toISOString())"
2026-04-30T08:29:16.247Z  # 正确的 UTC 时间

系统时区正确:

$ date
Thu Apr 30 16:29:31 CST 2026  # 北京时间
$ date -u
Thu Apr 30 08:29:31 UTC 2026  # UTC 时间

分析

问题出在 Gateway 内部的 conversation-logger 钩子。虽然配置了 userTimezone,但该钩子可能没有正确使用时区转换,直接把本地时间当作 UTC 写入。

临时解决方案

在汇总脚本中检测时间戳是否"在未来",如果是则说明时区标记错误,直接使用原始时间:

def parse_timestamp(ts: str) -> datetime | None:
    dt = datetime.fromisoformat(ts.replace("Z", ""))
    if ts.endswith("Z"):
        dt_as_utc = dt + timedelta(hours=8)
        if dt_as_utc > datetime.now() + timedelta(hours=1):
            # 时区标记错误,直接使用原始时间
            return dt
        else:
            return dt_as_utc
    return dt

相关配置

{
  "agents": {
    "defaults": {
      "envelopeTimezone": "local",
      "userTimezone": "Asia/Shanghai"
    }
  },
  "hooks": {
    "internal": {
      "entries": {
        "conversation-logger": {
          "enabled": true
        }
      }
    }
  }
}

建议

  1. conversation-logger 钩子应使用配置的 userTimezone 进行时间戳转换
  2. 或者在写入时明确使用 new Date().toISOString() 的正确行为(Node.js 已正确处理时区)

extent analysis

TL;DR

The conversation-logger hook in OpenClaw Gateway should be updated to correctly handle timezone conversions for timestamps.

Guidance

  • Verify that the userTimezone configuration is being used correctly in the conversation-logger hook to ensure accurate timezone conversions.
  • Consider using the new Date().toISOString() method to generate timestamps, as it correctly handles timezone conversions in Node.js.
  • Review the provided temporary solution in Python to detect and correct incorrect timezone markings in timestamps.
  • Check the configuration files to ensure that envelopeTimezone and userTimezone are set correctly.

Example

No code example is provided as the issue is more related to configuration and timezone handling.

Notes

The issue seems to be specific to the conversation-logger hook in OpenClaw Gateway and its handling of timezones. The provided temporary solution in Python may help mitigate the issue, but a more permanent fix would involve updating the hook to correctly handle timezone conversions.

Recommendation

Apply the workaround by using the provided Python script to detect and correct incorrect timezone markings in timestamps, until a permanent fix is available for the conversation-logger hook.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: conversation-logger timestamp timezone error - local time incorrectly marked as UTC [1 comments, 2 participants]