From 2ce487e999e2e70c28653d1d07fb0be653528317 Mon Sep 17 00:00:00 2001 From: tonmoy7722 <113795297+tonmoy7722@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:25:36 +0530 Subject: [PATCH] time --- script.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 99bb17b..ba005da 100644 --- a/script.js +++ b/script.js @@ -42,10 +42,17 @@ async function getWeatherData(location) { // Get hourly forecast data hourlyData = data.forecast.forecastday[0].hour; currentIndex = 0; // Reset index + + // Get current local time at the searched location + const localTime = data.location.localtime; + + // Format the local time using toLocaleTimeString + const formattedTime = new Date(localTime).toLocaleTimeString('en-US', { hour24: true }); + // Update weather info weatherInfo.innerHTML = ` -
Temperature: ${temperatureValue}°C
Weather: ${weatherConditionValue}