A date tool should be included by default
Status Fixed / completed
Maintainer reply ✓ Yes — dicksontsai
Workaround ✓ Mentioned in thread ↓
Activity 8 comments · opened Jun 26, 2025 · closed Jul 18, 2025
💡 Likely answer: A maintainer (dicksontsai, collaborator)
responded on this thread — see the highlighted reply below.
Summary
Claude Code CLI should include a built-in date/time tool to enable better temporal context and time-aware operations without requiring additional setup or external dependencies.
Problem Statement
Claude often uses outdated temporal information in its responses, referencing dates from its training data (e.g., treating 2024 as "current year" when we're actually in 2025). This creates several issues:
- Incorrect temporal context: Claude may suggest outdated practices, deprecated APIs, or reference events as "recent" when they're actually old
- Wrong date calculations: When generating code or scripts, Claude might use hardcoded dates from 2024 instead of dynamic current dates
- Misleading information: Users receive contextually incorrect information about timeframes, deadlines, or version compatibility
Without access to current date/time, Claude cannot:
- Provide accurate temporal context for its responses
- Generate code with correct current timestamps
- Make appropriate assumptions about software versions, compatibility, or current best practices
Proposed Solution
Include a built-in date tool that provides Claude with real-time temporal context to ensure accurate and current responses.
Core Functionality
- Current date/time awareness: Enable Claude to know the actual current date and time
- Temporal context: Allow Claude to make informed decisions based on current timeframe
- Dynamic date generation: Generate code and responses with correct current timestamps
- Version/compatibility awareness: Help Claude suggest current best practices and compatible versions
Example Impact
Before (without date tool):
Claude: "In 2024, you should use Node.js 18..."
Claude: "This year (2024), the latest React version is..."
After (with date tool):
Claude: "As of June 2025, you should use Node.js 22..."
Claude: "Currently in 2025, the latest React version is..."
Benefits
- Accurate temporal context: Claude provides responses based on current date/time instead of training data timestamps
- Correct code generation: Generated scripts and applications use current dates instead of hardcoded old dates
- Better recommendations: Claude can suggest current best practices, latest versions, and up-to-date approaches
- Contextual awareness: Claude understands the actual timeline for project planning, deadlines, and scheduling
Use Cases
- Code generation: Creating scripts with current timestamps and dates
- Project planning: Accurate timeline suggestions and deadline calculations
- Version recommendations: Suggesting current stable versions of frameworks and tools
- Log analysis: Proper temporal context when analyzing recent vs. old log entries
- Documentation: Generating documentation with current dates and relevant timeframes
- API integration: Using current timestamps for API calls and data processing
Alternative Considerations
- Integration with existing system date tools
- Optional vs. mandatory inclusion
- Performance impact assessment
- Configuration options for default formats/timezones
Implementation Notes
- The tool should automatically provide current date/time context to Claude for every interaction
- Consider making this a default tool that's always available (similar to filesystem access)
- Should include timezone information and locale support
- Could be implemented as a simple tool that Claude can query when it needs temporal context
- Priority should be on providing accurate current date/time rather than complex date manipulation features
8 Comments
Pretty sure that Claude 4 has today's date included inside of system prompt in each call?
https://docs.anthropic.com/en/release-notes/system-prompts
You have a couple existing options here:
dateordate +"%Y-%m-%d"By the way, @patkepa , Claude Code does not use the same system prompt as https://docs.anthropic.com/en/release-notes/system-prompts . As stated in that website, it applies to claude.ai and the mobile apps but not the Anthropic API. We do add the date to Claude Code's system prompt, but it may get lost in all the other context.
Reopening Discussion: A Production-Ready Date/Time Solution for Claude Code
@dicksontsai Thank you for your response. After researching how other AI coding tools handle this challenge and considering Claude Code's architecture, I'd like to propose a more comprehensive solution that addresses the root issues.
The Current Problem
You mentioned that the date "may get lost in all the other context" - this is precisely the issue. The current workarounds (manual
datecommands or hooks) are band-aids that don't address the fundamental problem: Claude needs reliable, automatic access to temporal context.Research Findings
After analyzing how tools like Cursor, GitHub Copilot, and VS Code handle this:
${CURRENT_YEAR}that always workProposed Implementation
1. Enhanced Environment Context (Primary Solution)
Extend the existing
<env>tag to always include temporal information:Why this is the best approach:
2. Dynamic Variables (Secondary Enhancement)
Support for template variables in prompts and code generation:
3. Settings Configuration (User Control)
Allow users to configure date format preferences in
.claude/settings.json:Implementation Benefits
Real-World Impact
Currently, Claude often provides outdated information:
With this implementation:
Technical Implementation
The implementation would be minimal:
Addressing Concerns
"Just use bash date command"
"Use hooks to catch old dates"
"It's in the system prompt"
Community Need
This isn't an edge case. Common use cases include:
Request
Given that:
Could we reopen this issue for proper implementation? I'm happy to contribute code or create a more detailed RFC if that would help.
The goal is simple: Make Claude Code as reliable with dates as it is with file paths.
What we did for WebSearch in v1.0.36 was to tell it to look at today's date in <env>. We didn't do anything extra.
The easiest way to contribute is not to provide a more detailed RFC but rather to write a hook demonstrating what 2 would look like.
Re-opening because "automatically injects contextual information into every interaction" seems like the most sensible solution to implement from the above.
Hi @dicksontsai\! 👋
Thank you for the guidance on implementing a hook solution - it was exactly the push I needed to dive deeper into this.
I've spent some time building out what you suggested, and honestly, it turned into quite the rabbit hole (in a good way\! 😅). Started with a simple hook and ended up with a comprehensive solution that I'm pretty excited about.
What I Built
I created two versions because I couldn't decide between "simple and fast" vs "comprehensive":
Smart Hook (my recommendation): Adds temporal context only when it makes sense - like when you're creating documentation or commit messages. Keeps the overhead minimal.
Complete Hook: Goes all-in with content guidance, template variables, and quality checks. It's more comprehensive but still lightweight.
Real-World Impact
The difference is honestly pretty striking:
Try It Out
Repository with full details: https://github.com/gianlucamazza/claude-code/tree/feature/smart-temporal-context
I've been using it for a few days now and it feels natural - Claude just... knows what year it is\! 😄
Would love to hear thoughts from you and the team. Happy to iterate on anything or answer questions.
Thanks again for the direction - this was a fun problem to solve\! 🚀
Thanks for trying out the idea! I like the setup but it actually won't work at the moment, since according to our documentation, Claude does not see stdout. Unfortunately, the results you see are likely a hallucination.
Your prototype illustrates that we should implement a Start hook https://github.com/anthropics/claude-code/issues/2876 to inject that basic temporal context at the start of an agent loop:
With v1.0.55, you can now inject the current time using a UserPromptSubmit hook. Example: https://docs.anthropic.com/en/docs/claude-code/hooks#userpromptsubmit-example%3A-adding-context-and-validation (but ignore the validation part)
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.