Hey guys,
I’m getting an epoch time from a REST API, how do I convert that to a regular timestamp?
Hey guys,
I’m getting an epoch time from a REST API, how do I convert that to a regular timestamp?
You want the timestamp
filters, for example:
{{ 1537607983 | timestamp_local }}
Replace the number with whatever holds the time.
So basically, a “regular timestamp” is an epoch time. The only thing you might have to do is convert it to a float or int if it’s represented as a string from the REST API.
Basically every time in linux as a whole is epoch time.
Mine wasn’t working earlier because the time returned was not seconds from epoch, but actually milliseconds from epoch. To solve this I did:
value_template: "{{ value_json['message']['list'][0]['prices']['U91']['updated'] | multiply(0.001) | round(0) | timestamp_local }}"