Convert UNIX Time to normal Time

Hi,

I am getting from a weatherstation the time of the latest values via unix time.

I am trying now to convert this via a template, but it doesnt work.

I have the following template, which delivers me the unix time:

sensors:
  weather_datetime_template:
    value_template: '{{ states.sensor.weather_datetime.state }}'  

What do I have to do to get a readable date/time?

Br,
Johannes

What do you mean by “unix time”? is it a epoch timestamp or something else?

Post the state of the sensor.weather_datetime.

Hi,

This is the state: 1547396700.0

Br,
Johannes

Try This:
‘{{ states.sensor.weather_datetime.state | int | timestamp_custom("%d.%m.%Y %H:%M")}}’

2 Likes

try:

{{ states.sensor.weather_datetime.state | timestamp_custom('%Y/%m/%d %H:%M:%S') }}

that will return the date & time in this format “2019/01/13 11:25:00” based on the state you gave me above.

And now for shameless self-promotion I created a thread on manipulating dates & times here:

Maybe you will find it helpful.

1 Like

Thanks daveyrb, that worked.