The date comes from your app’s clock, not a model.
dotnet add package RecursiveAI.OneLlmRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneLlm.Templating; var options = new TemplateRenderOptions { TimeProvider = TimeProvider.System }; Console.WriteLine(Template.Render( "Today: {{now | date \"2006-01-02\"}}", null, render: options));
2006-01-02 is a Go-style layout meaning yyyy-MM-dd, not a fixed date.
On November 29, 2026, this printed:
Today: 2026-11-29Unzip the example, then dotnet run.
The full program
The download renders the same prompt but fixes the clock at July 4, 2030, in UTC. It checks the exact string and then shows the error you get when you omit the clock. Nothing is sent to a model.
using OneLlm.Templating; const string prompt = "Today: {{now | date \"2006-01-02\"}}"; var clock = new FixedClock(new DateTimeOffset( 2030, 7, 4, 9, 5, 6, TimeSpan.Zero)); var options = new TemplateRenderOptions { TimeProvider = clock }; string rendered = Template.Render(prompt, null, render: options); if (rendered != "Today: 2030-07-04") throw new InvalidOperationException($"Unexpected prompt: {rendered}"); Console.WriteLine(rendered); try { Template.Render(prompt, null); throw new InvalidOperationException("Expected a missing-clock error."); } catch (TemplateException error) { Console.WriteLine(error.Detail); } sealed class FixedClock(DateTimeOffset utc) : TimeProvider { public override DateTimeOffset GetUtcNow() => utc; public override TimeZoneInfo LocalTimeZone => TimeZoneInfo.Utc; }
Today: 2030-07-04 error calling now: no TimeProvider was given to the render, so there is no clock
If you call now without setting TemplateRenderOptions.TimeProvider, rendering throws TemplateException; it does not silently read the system clock.
Variations
To format a timestamp you already have, pass it to date directly. No clock is required in this case.
using OneLlm.Templating; Console.WriteLine(Template.Render( """{{date "2006-01-02" "2030-07-04T09:05:06Z"}}""", null));
2030-07-04Related recipes
Render a prompt template · Fail on a missing prompt key
The short answer
Use {{now | date "2006-01-02"}} in the prompt and pass a TimeProvider to Template.Render. Use TimeProvider.System for the machine’s current local date. Use a fixed clock in a test so the expected string doesn’t change depending on when the test runs. Rendering produces text locally; it doesn’t call a model.
How do I add today’s date to an LLM prompt?
Use now at render time and date to keep just the calendar date. The | sends the value of now into date as its last argument. The layout 2006-01-02 is Go template syntax: it means four-digit year, two-digit month, and two-digit day. It doesn’t make the date come out as January 2, 2006. Don’t substitute the .NET format string yyyy-MM-dd; see the date entry in the template reference.
Pick the clock based on what “today” means in your application. now uses the clock’s local time, so machines in different time zones can report different dates at the same instant. The fixed clock in the download overrides both the instant and the time zone. That keeps the test independent of the computer’s clock and local zone. If you’re reporting on a date from a record rather than today, pass the record’s timestamp to date as in the variation instead of deriving a new one at render time.