Customize timestamp "for item" in markdown card

Hallo!

I’m having a markdown card to show recently connected devices with the “AsusRouter”-Integration.
this is my card content:

- type: markdown
    content: >
      <h3> Zuletzt verbunden:</h3> {% for item in state_attr("sensor.asus_gt_ax11000_latest_connected","list") | sort(attribute='connected') %}
      <b> {{item.name}} </b> {{item.connected}} <br>
      ({{item.connection_type}} / {{item.ip}} / {{item.mac}} / Gast: {{item.guest}})<br><hr>
      {%- endfor %}

the output of “{{item.connected}}” is the timestamp in this format: “2022-11-30 05:25:39.885126+00:00”

Could anybody tell me how i could get it like this: " Mon., 28.Nov.2022 - 05:46 Uhr (%a., %d.%b.%Y - %H:%M Uhr)".

Thanks to all in advance!

I don’t use Asus router integration, so I don’t know if item.connected isbeing returned as a string or datetime object, but try the following:

{{ (item.connected | as_datetime).strftime("%a., %d.%b.%Y - %H:%M Uhr") }}

If you get a TypeError in the Template editor tool you need to remove the | as_datetime.

1 Like

Without “as_datetime” did it. Thank you!!!

1 Like