Mabaelst
(Bart Teuwen)
June 26, 2025, 1:41pm
1
Hello everyone,
if I
{{now()}}
type I get the current time, if I e.g.
{{states.light.keuken_bank.last_changed}}
I get the time that this entity was last changed.
What I suddenly notice is that these two differ by 2 hours.
How does this happen and how do I solve this?
tom_l
June 26, 2025, 1:47pm
2
They are the same time. It is just that one is time zone aware and the other isn’t:
EDIT: or more correctly one is local time the other is UTC as Drew points out below.
Try this:
{{ states.light.keuken_bank.last_changed|as_local }}
1 Like
Those are the same time…
now()
returns time in your local time zone, HA stores all times as UTC.
Mabaelst
(Bart Teuwen)
June 26, 2025, 1:52pm
4
Thank you very much. This solved my problem!!
WallyR
(Wally)
June 27, 2025, 3:28pm
5
I do not know what your problem or solution is, but beware that the local timezone might have daylight savings and UTC do not, so what is now +2 might be +1 or +3 in 6 months time.
HA have functions to convert time values that takes this into account.
tom_l
June 27, 2025, 9:39pm
6
|as_local
will include DST in the conversion.