Fixing Claude's Time Hallucinations in Claude Code with Hooks

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:
- Open or create ~/.claude/settings.json (or ask Claude Code to do it for you)
- 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.
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
👀 See Also

Claude User Preferences: A Redditor's Setup for Concise, Critical Responses
A Redditor shares their Claude User Preferences tweaks to get less corporate, more critical responses. Includes tips to avoid repetition, start with conclusions, and simplify punctuation.

Using the Dispatcher Pattern to Reduce Claude API Costs by 95%
A developer reduced Claude API costs from $800-$2,000/month to $215/month by implementing a dispatcher pattern that delegates heavy work to Claude Code CLI on a $200/month Max subscription, with API overhead costing only $5-15/month.

How a Non-Coder Built a Reusable Claude Workflow for Founder Content Marketing
A former magazine editor with zero coding background shares how they accidentally built a repeatable Claude workflow for solo founder content marketing: dump raw thoughts, then restructure with Claude into platform-specific formats.

Claude Code: Context Management Over Prompt Engineering
A developer shares that after a year of using Claude Code, the key skill isn't prompt wording or model selection, but providing comprehensive project context upfront to get better results.