How to obtain HA timezone in Lovelace?

I am trying to fix a couple of custom cards that assume that the time data they are displaying (specifically sunrise and sunset) is in the time zone of the browser / app being used, vs being in the time zone of the Home Assistant instance.

By creating 2 sensors on HA that are pre-formatted as displayable times in the correct timezone, I can pick those up in the card and display them. However, this is a bit of a kludge since it requires creating these sensors. I would like to retrieve, in the Lovelace card, the timezone that the Home Assistant is using and then use that as input into the Javascript IntlDateFormat function to convert it for correct display. Is there a built-in way to retrieve the configured timezone?


You can make a template sensor with the current timezone, current dst, or offset.

- sensor:
  - name: Time Zone
    unique_id: time_zone
    state: "{{ now().tzinfo }}"
      dst: "{{ now().dst }}"
      offset: "{{ now().isoformat()[-6:] }}"
1 Like

Yes, that’s a variant of what I have already, but I’ll play around with it. I was hoping that there may just be something built in. Then maybe we could encourage people who write these cards to display the correct times!

The frontend has access to the backend, you’ll have to look through the api. If that’s what you want, you should ask in developers not configuration