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

Model Routing Cut API Costs by 85% vs Claude Max Subscription – A Developer's Analysis
A Claude Max subscriber tracked token usage and found only 15% of tasks needed Opus. Switching to API routing (Sonnet for routine tasks, Opus for hard reasoning) dropped monthly cost from $200 to ~$30 with identical output quality.

Practical Claude Code Workflow Tips for Complex Development Projects
A Claude Pro user shares specific workflow strategies for developing complex audio plugins, including using planning mode for major features, creating context files, managing token usage, and implementing validation steps.

KV Cache Quantization Issues in Local Coding Agents at High Context Lengths
A Reddit analysis identifies aggressive KV cache quantization as the cause of infinite correction loops and malformed JSON outputs in local coding agents like Qwen3-Coder and GLM 4.7 at 30k+ context lengths, recommending mixed precision or reduced context as workarounds.

Running a Fully Local AI Agent on a 6GB VRAM Laptop: A Step-by-Step Guide for Students
Explore how students can leverage 6GB VRAM laptops to run AI agents locally, without relying on costly APIs. Our guide breaks down essential steps and tools.