date time

---
- hosts: localhost
  tasks:
    - debug:
        var: hostvars['localhost']['ansible_date_time']['iso8601']

ok: [localhost] => {
    "hostvars['localhost']['ansible_date_time']['iso8601']": "2022-07-22T10:28:46Z"

However:
---
- hosts: localhost
  tasks:
    - debug:
         var: hostvars['localhost']['ansible_date_time']['iso8601']
      register: date_time
    - debug:
         msg: "{{ ( (date_time).total_seconds() / 3600 ) | int }}"

does not work.

What do you mean by "does not work"?
What do you expect to happen?
I.e. what are you trying to do/calculate?

If you need the number of second since epoch, then that is already
available as ansible_date_time.epoch_int

This is because the difference in variable:
"2022-07-22T10:28:46Z" must be 2022-07-22T10:28:46Z without quotes.

If

I want to compare two date times and get the difference in seconds.