title: How to display sunrise and sunset time in the local time of the city that is being searched
body: <p>I have created a project that displays the sunrise and sunset by searching the name of the city. I use the open weather API.</p>
  <p>However, when I search for a city with different timezone than my country (Greece), it converts the sunrise-sunset times to Greece's local timezone.</p>
  <p>For example, I search &quot;Albania&quot;</p>
  <p><a href="https://i.stack.imgur.com/hpQjN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hpQjN.png" alt="enter image description here" /></a></p>
  <p>The sunrise and sunset times in Albania are displayed in Greece's timezone.
  (Note: Greece is 1 hour ahead of Albania)</p>
  <p><a href="https://i.stack.imgur.com/y5b1l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y5b1l.png" alt="enter image description here" /></a></p>
  <p>Normally, the sunrise-sunset times in Albania are: 7:02 AM and 4:35 PM.</p>
  <p>However, it displays 8:02 and 17:35 which are 1 hour ahead of the normal sunrise-sunset times because they are converted to Greece's local timezone.</p>
  <p><strong>MY CODE</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let weather = {
    apiKey: "XXXXXXXXXXXXXXXXXXXXX",
    fetchWeather: function (city) {
      fetch(
        "https://api.openweathermap.org/data/2.5/weather?q=" +
          city +
          "&amp;units=metric&amp;lang=en&amp;appid=" +
          this.apiKey
      )
    
        .then((response) =&gt; {
          if (!response.ok) {
            alert("No weather found.");
            throw new Error("No weather found.");
          }
          return response.json();
        })
        .then((data) =&gt; this.displayWeather(data));
    },
    
    //fetching the API parameters:
    displayWeather: function (data) {
      const { name } = data;
      const { sunrise } = data.sys;
      const { sunset } = data.sys;
  
    
  //Displaying the results:
      document.querySelector(".city").innerText = "Weather: " + name;
      document.querySelector(".sunrise").innerText = "Sunrise: " + window.moment(sunrise * 1000).format('HH:mm a');
      document.querySelector(".sunset").innerText = "Sunset: " + window.moment(sunset * 1000).format('HH:mm a');
      document.querySelector(".weather").classList.remove("loading");
      document.body.style.backgroundImage =
        "url('https://source.unsplash.com/1600x900/?')"; 
    },
  
    
    search: function () {
      this.fetchWeather(document.querySelector(".search-bar").value);
    },
  };
  
  document.querySelector(".search button").addEventListener("click", function () {
    weather.search();
  });
  
  document
    .querySelector(".search-bar")
    .addEventListener("keyup", function (event) {
      if (event.key == "Enter") {
        weather.search();
      }
    });
  //Displaying Athens sunrise sunset on page load
  weather.fetchWeather("Athens");</code></pre>
  </div>
  </div>
  </p>
  <p><strong>I want it to display the normal sunrise-sunset local time for each city without them displaying in Greece's timezone.</strong></p>
  <p>Can anyone help me? I am begginer so I would appreciate if you could elaborate on your answer.</p>