Datetime in sensor attributes

I have a custom sensor who writes some datatime attirbutes. How should it store them?

Right now I store them like this:
datetime.datetime.fromtimestamp(event[‘startdate’]).strftime(’%Y-%m-%d %H:%M:%S’)

I would like to store it in a way that the home assistant frontend would translate these utc times to local time.

this is the solution
dt_util.as_local(dt_util.utc_from_timestamp(event[‘start’))

1 Like