Fixing Claude's Time Hallucinations in Claude Code with Hooks

✍️ OpenClawRadar📅 Published: April 15, 2026🔗 Source
Fixing Claude's Time Hallucinations in Claude Code with Hooks
Ad

A Reddit user identified and solved a specific issue with Claude Code where the AI assistant makes incorrect time-based suggestions due to lacking real-time clock access.

The Problem

Claude doesn't have access to a real-time clock. While it receives today's date at session start, it doesn't get the current time. This causes Claude to guess the time - often incorrectly - leading to inappropriate suggestions like "it's late, get some rest" when it's actually noon. This solution only works in Claude Code, not the web or desktop versions.

The Solution

The fix involves adding a single hook to Claude Code's settings file:

  1. Open or create ~/.claude/settings.json (or ask Claude Code to do it for you)
  2. Paste this configuration:
{
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "echo \"Current time: $(date '+%A %Y-%m-%d %I:%M %p %Z')\""
          }
        ]
      }
    ]
  }
}

The solution works immediately without requiring a restart.

Ad

How It Works

Every time you send a message, the hook runs the date command and injects the output into Claude's context behind the scenes. Users don't see this output - Claude sees something like "Current time: Monday 2026-04-06 03:39 AM EDT." Because the hook fires on every message, Claude can also detect when you've stepped away and returned by observing the time gap between messages.

This approach leverages Claude Code's hooks feature - shell commands that fire automatically on specific events like UserPromptSubmit.

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also