# Server date in Ansible/J2?

**URL:** <https://forum.ansible.com/t/server-date-in-ansible-j2/21967>\
**Category:** Ansible Project\
**Created:** [July 9, 2016, 2:03am UTC](https://forum.ansible.com/t/server-date-in-ansible-j2/21967 "2016-07-09T02:03:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jp11](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jp11](https://forum.ansible.com/u/jp11)\
**Post date:** [July 9, 2016, 2:03am UTC](https://forum.ansible.com/t/server-date-in-ansible-j2/21967/1 "2016-07-09T02:03:48Z")

</div>

```auto
I have what seems to be a simple question that I can't find on the web. How do I get the current date from the Ansible server into a J2 variable? I know how to do it with {{ ansible_date_time.date }} but that's from the remote node at the time Ansible collected facts (which could be cached), NOT "now" on the server I'm running on...right?

Use case (this works, but it's remote node "setup" (get facts) time, not local server "now" time):
 - name: Update image_release file
   lineinfile:
     dest=..../image_release
     state=present
     insertbefore=BOF
     line='{{ ansible_date_time.date }} {{ image_release }}'

How do I get "now" on the server I'm running on?

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 10, 2016, 7:41pm UTC](https://forum.ansible.com/t/server-date-in-ansible-j2/21967/2 "2016-07-10T19:41:16Z")

</div>

Check out lookups  
[https://docs.ansible.com/ansible/playbooks\_lookups.html](https://docs.ansible.com/ansible/playbooks_lookups.html)

{{ lookup('pipe','date') }}

---

<div class="post-metadata">

**Author:** ![jp11](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jp11](https://forum.ansible.com/u/jp11)\
**Post date:** [July 11, 2016, 3:15pm UTC](https://forum.ansible.com/t/server-date-in-ansible-j2/21967/3 "2016-07-11T15:15:19Z")

</div>


