Timezone on OH3 Clock Widget

Platform information:
Hardware: Raspberry Pi 3
OS: OpenHABian
openHAB version: 3.1.0

Hi, I have a friend who lives in a different country to me and I’m trying to make a clock widget with the Swiss timezone (UTC+01 & +02) However I cannot figure out how to do it, I’ve looked at the community here, Google, OpenHAB documentation, the dayjs date and time formatting options, and tried myself and haven’t found anything relevent to the problem. I can’t change the date on the Raspberry Pi because I have another clock widgit with British time. Attached at the bottom should be what I’m trying to do, the left side needs to be British time and the right needs to be Swiss time.

Ideally I want to take the current timezone on the Raspberry Pi and add one hour so It’ll change when the clocks change due to daylight savings automatically.

Thank you,
-Koi

1 Like

I don’t believe the timezone extension for dayjs is enabled, but if you really just need the display to be one hour ahead then you should just be able to use the dayjs add method

=dayjs([time isostring]).add(1,"hour")

Sorry but I’m a complete beginner with this, would I just type in

=dayjs(HH:mm:ss).add(1,“hour”)

Into the Time Format field?

Sorry for the terrible formatting, currently away from my computer so have to use my phone to type this.

Thank you

Sorry, I misinterpreted at first. I thought you were trying to make your own clock widget, not use the built-in system widget.

Unfortunately the system widget does not have the capability that you want. The system widget gets the time by using the dayjs() object which when called like that without any inputs simply returns the current system time. A dayjs object like that, if you have access to it is very powerful and allows all manner of easy manipulations to the time before you format it for output, however, in order to make the clock widget user-friendly and simple, no part of the dayjs object other than the format options are exposed to the user so there is simply no way to change the time.

Making your own clock widget, it would be very easy to use code such as I first proposed to get whatever changes to the time you wish. On the other hand getting it to refresh at 1 second or even 1 minute intervals would be very tricky (if not impossible, I’ve never tried).

Hi all, I know this thread is a little old but I am just trying to do a similar thing with the oh-clock-card. Having hunted for more info I can’t really find a nice way around this using the widgets. I would like to use it to display multiple timezones simultaneously, am I underestimating it to feel that the oh-clock-card should include an offset option to allow for multiple timezones to be displayed on pages?

@KoiV did you manage to display the 2 timezones in the end?

Thanks in advance

That this doesn’t exist yet is merely a reflection of the fact that none of the UI devs 1) have noticed that this has been called for or 2) had a reason to add this yet. The best way to try and fix both of those is to add an enhancement request to in the UI repository issues:

Thanks, @JustinG I have done so! Fingers crossed it gets noticed.