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 Code Auto-Update Nearly Bricks PC — DNS Nightmare After Driver Update
A Reddit user reports Claude Code automatically updated GPU drivers, causing boot failure and a DNS routing issue fixed only via PowerShell NRPT rule removal.
Claude + MCP Browser: User Reports Supercharged Web Access
A Claude user explains how hooking Claude to an external browser via MCP allowed it to navigate previously inaccessible sites, and wonders if Claude can use the browser's model tokens.

Preventing output drift in long Claude threads by anchoring high-quality responses
A user describes how Claude responses degrade after 30-40 messages, and how they anchor the best mid-thread output to start fresh conversations.

Claude Code Headless Mode with --print Flag
Claude Code can run in headless mode using the --print flag, allowing prompts to be piped in for automated output without interactive sessions. This enables integration into CI/CD pipelines, git hooks, and bash scripts.