Hi i need help with my weather api in Javascript with Openweathermap API. I want it to display the time for the sunrise and the sunset of the searched city. Currently its just showing the unix time like for example: 1686799061. I want it to say the time in like 05:43 or something else. I hope yall can help me. My code strips for the sunrise and sunset are the following:
How to fetch the time:
const { sunrise } = data.sys;
const { sunset } = data.sys;
showing:
document.querySelector(".sunrise").innerText = "Sonnenaufgang: " + sunrise;
document.querySelector(".sunset").innerText = "Sonnenuntergang: " + sunset;
I rly hope someone can help me with that!!!
I tried to do it with the
.format('HH:mm a')
which just causes my weather api to crash and not showing anything. I really need help with that one.