Calculate time between now() and particular attribute value

I would like to show something like “countdown timer” in HA dashboard, but have no idea how to do it.
Value should be time difference between current datetime and attribute next_event of scheduler entity value. See picture below:

Thanks a lot for any hint!

You need a template sensor with device_class: timestamp. In your configuration.yaml, insert this, making sure you only have one top-level template: section:

template:
  - sensor:
      - name: Tarif next event
        state: "{{ state_attr('schedule.nizky_tarif', 'next_event') }}"
        device_class: timestamp

Reload template entities (Developer Tools / YAML / Template entities) and you should see the new sensor. When you add that to an Entity or Entities card it will show the time to go, for example “In 3 hours”.

type: markdown
content: >-
  {{-((as_timestamp(now())-as_timestamp(state_attr('schedule.nizky_tarif','next_event'),0))/86400)|int  -}}D 
  {{-(((as_timestamp(now())-as_timestamp(state_attr('schedule.nizky_tarif','next_event'),0))%86400)/3600)|int  -}}:
  {{-(((as_timestamp(now())-as_timestamp(state_attr('schedule.nizky_tarif','next_event'),0))%86400)%60)|int  -}}

This will show days and hours and minutes.
There might be some fiddling to do if it is off by some hours, which is due to timezone differences.

For me

{{ ((state_attr('sensor.mysensor1', 'nextdate_start_tz') | as_datetime - now()).total_seconds() // 60 )|replace('.0','')|replace('-','')}}

but if the format “nextdate_start_tz” is different from the ISO date, markdown hides the card,
some idea?