Date time incorrect today

Using a markdown card to display the time.

{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%A %B %-m') }}

But this is displaying in the template editor (and the markdown card) as Monday August 8, instead of 9. Locale is set correctly (Europe/Zurich) in the UI and Windows 10 system time/date is also correct. Where else can I look to correct this?

Seems like a parser issue getting the 8/9 wrong, but I’ve no idea where else to troubleshoot. Ideas?

“%m” is the month, so 8.
You likely want “%-d”

Bloody hell I was just about to delete the post… from the SHAME.
Thanks!

1 Like

A long time ago, users were advised to avoid using the now() function in a template because it would not make the template update itself every minute. The recommendation was to use sensor.date_time or one of its variants (like sensor.date_time_iso or sensor.time).

That advice was withdrawn many versions ago when the now() function became a first-class citizen in templates (it causes the template to be evaluated every minute, on the minute). If you wish, your template can now be written like this:

{{ now().timestamp() | timestamp_custom('%A %B %-d') }}
1 Like

That very same admonition did have me confused – my code has a mixture of now() and sensor.date_time, though I’d never really understood why both seemed to work perfectly well. Appreciate the education and will shift to consistent use of now()!