[Bug] Agent invents timestamp when writing to files — currentDate injected but no currentTime

Resolved 💬 5 comments Opened May 19, 2026 by satel-kalletuulos Closed Jul 6, 2026

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

  1. Instruct Claude Code to create a timestamped archive file (e.g. archive-YYYYMMDDHHMM.md)
  2. 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.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗