Lesson 20easy10 min

Equipping the AI Agent with Date and Time Awareness

Provide the agent with current date, time, and day-of-week context to ground relative scheduling queries.

Learning Objectives

  • Inject current date and time expressions into the system prompt
  • Build a custom Date Calculator tool for relative queries (tomorrow, next Friday)
  • Prevent LLM timestamp confusion across UTC and local timezones

Equipping the AI Agent with Date and Time Awareness

LLMs do not have an internal clock. If you tell an agent "Check today's events", it cannot determine what day "today" is unless explicitly grounded.

Grounding via System Prompt Expressions

The cleanest method in n8n is dynamically injecting the current timestamp into the system prompt:

CURRENT TEMPORAL CONTEXT:
Today's Date: {{ $now.toFormat('EEEE, MMMM dd, yyyy') }}
Current Local Time: {{ $now.toFormat('hh:mm a ZZZZ') }}
ISO Timestamp: {{ $now.toISO() }}

When n8n invokes the agent, it evaluates these expressions before sending the prompt to the model. The agent instantly knows that today is Tuesday, September 15, 2026.