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

Pre-coding routine with Claude Code: 5 MCP servers before writing a line
A developer shares a 60-90 second routine using 5 MCP servers (memory, codebase graph, Tavily search, Context7 docs) and safety hooks to dramatically reduce hallucinations and wasted edits.

Stop Claude's Em Dashes with One Line in Preferences or Claude.md
Add a specific sentence to your Claude.ai profile preferences or Claude.md to reduce em dashes by ~98%. This is a practical tweak tested by the community.

Most People Use Claude at 5% of Its Capacity – Here's How to Fix It
After 60+ hours testing prompts on Claude Opus 4.7, a user shares a 5-step recipe: assign role, load specific context, set constraints, define output format, add forcing function.

Claude Code Token Waste Fix: Disable Attribution Header for Better Cache Hits
Setting CLAUDE_CODE_ATTRIBUTION_HEADER=false in your shell configuration can improve Claude Code's cross-session prompt cache hit rate from 48% to 99.98%, reducing system prompt processing costs by 7x per session.