eggman
(bertie basset)
September 28, 2019, 11:20am
1
I’m sure this is simple but I’m obviously not searching for the right information. I have an entity with an attribute which is a date string. I’d like to display it as ddmmyy.
I’ve tried numerous things, this being the last:
{{ strptime(state_attr(‘sensor.bin_collections’, ‘lastUpdate’),“%d%m%y”) }}
It just gives me 2019-09-28T06:26:11+00:00 which is the original value of the attribute. What am I doing wrong?
tom_l
September 28, 2019, 11:26am
2
Try:
{{ as_timestamp(state_attr('sensor.bin_collections', 'lastUpdate')) | timestamp_custom('%d%m%y', True) }}
Or this:
{{ state_attr('sensor.bin_collections', 'lastUpdate').strftime('%d%m%y') }}
The first one will be in local time, the second will be in UTC (I think).
1 Like
eggman
(bertie basset)
September 28, 2019, 11:58am
3
Thanks, the 1st one was exactly what I was looking for.
1 Like