#Hi, ```{{ strptime(state_attr("sun.sun

1 messages · Page 1 of 1 (latest)

spiral rose
#

with ValueError: Template error: strptime got invalid input '2023-10-26T11:26:01.237783+00:00' when rendering template '{{ strptime(state_attr("sun.sun", "next_rising"), "") }}' but no default was specified
Based on https://www.programiz.com/python-programming/datetime/strptime the strptime() should be in this format: 2018-06-21 00:00:00 not 2023-10-26T11:26:01.237783. How do I fix the template?

#

Note: I don't know Python.

near token
#

what are you trying to do?

#

if you want to convert it to a datetime, just use {{ state_attr("sun.sun", "next_rising") | as_datetime }}

spiral rose
#

Thanks for the quick reply. I'll test your code and add it to my examples list. I got it to work (after a few hours) using this:```The sun will rise at {{ as_timestamp(state_attr("sun.sun", "next_rising")) | timestamp_local }}.