[Bug] Agent invents timestamp when writing to files — currentDate injected but no currentTime
Description
When Claude Code writes a timestamp into a filename, document header, version history row, or journal entry, it silently fabricates the time component. The system prompt injects currentDate (e.g. Today's date is 2026-05-19) but no currentTime. The agent has the date but no authoritative time source, so it guesses.
Steps to reproduce
- Instruct Claude Code to create a timestamped archive file (e.g.
archive-YYYYMMDDHHMM.md) - Observe the filename — the time component (HHMM) is invented, not the actual current time
Expected behavior
The timestamp matches the actual wall-clock time at the moment of writing.
Actual behavior
The agent fabricates a plausible-looking but incorrect time (e.g. writes 202605191456 when the real time was 202605191200). The failure is silent — the agent does not warn that it is guessing.
Root cause
currentDate is injected into the system prompt at session start. currentTime is not. Node.js has new Date() which gives the full current date and time — this is already available in the Claude Code runtime.
Suggested fix
Inject currentTime into the system prompt alongside currentDate:
const now = new Date();
// e.g. "Current time is 2026-05-19T12:08:00+03:00"
Workaround
Add to CLAUDE.md: instruct the agent to always run date via Bash before writing any timestamp and use the returned value.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗