Ansible in a Minute · Ansible Core ·
Use now to get the current time in a template
Short answer
Use now() when you need the current time, not the time facts were gathered.
Subscribe for updates
Get an email whenever we publish new guides and blog posts. Unsubscribe anytime.
By subscribing you agree we may email you about Ansible in a Minute and related Level Up Labs updates. We store your address in the same lead sheet as our contact form.
Request
print current UTC time with now() fmt ISO
Example
A quick heads-up: Every environment is different. Review and test this example before you run it on systems you care about.
---
- name: Print current UTC time with now() fmt ISO
hosts: all
gather_facts: true
tasks:
- name: Print current UTC time with now() fmt ISO
ansible.builtin.debug:
msg: "{{ ansible_date_time.iso8601 }}"How it works
This example prints ansible_date_time.iso8601 after facts are gathered. That stamp stays fixed for the play. Use now() when the template must reflect the current clock instead of gather time. now() evaluates when the template renders.
When to use it
- Timestamping a report or artifact name
- Recording the time a task actually ran
Requirements
- Ansible: >=2.14
Validation
- Syntax validated
- Not execution-tested
- Last verified 2026-09-16
Notes
now(utc=true) uses UTC. fmt is a Python strftime string. You do not need gather_facts to use now().
Reference
- Templating now (Ansible docs)
Built for every Ansible use case in every organization
BacklogZero can generate this kind of automation in your environment, just like it did here.