{"id":6049,"date":"2026-02-21T09:17:37","date_gmt":"2026-02-21T09:17:37","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=6049"},"modified":"2026-02-21T09:47:53","modified_gmt":"2026-02-21T09:47:53","slug":"create-temperature-widget-using-javascript-php-auto-location-live-weather-api","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/","title":{"rendered":"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API)"},"content":{"rendered":"<p>If you want to display <b>real-time temperature<\/b>, humidity, weather description, and day\/night status on your website, this tutorial will help you build a fully functional <b>Temperature Widget using JavaScript and PHP<\/b>.<\/p>\n<p><b>This widget:<\/b><br \/>\n\u2714 Detects user location automatically via IP<br \/>\n\u2714 Fetches live weather data using the Open-Meteo API (no API key required)<br \/>\n\u2714 Displays:<\/p>\n<ul>\n<li>Current temperature in Celsius<\/li>\n<li>City \/ Country<\/li>\n<li>Weather description (e.g., Partly Cloudy)<\/li>\n<li>Humidity<\/li>\n<li>Current date &#038; time<\/li>\n<li>Day\/Night indicator icon<\/li>\n<\/ul>\n<p>We\u2019ll use:<\/p>\n<ul>\n<li>Frontend: HTML + CSS + JavaScript\n<ul>\n<li><b>HTML<\/b> for the widget structure<\/li>\n<li><b>CSS<\/b> for styling<\/li>\n<li><b>JavaScript<\/b> to fetch and display weather data dynamically<\/li>\n<\/ul>\n<\/li>\n<li>Backend: PHP\n<ul>\n<li><b>PHP<\/b> to handle server-side requests and fetch weather data from the API<\/li>\n<\/ul>\n<\/li>\n<li>Weather API: Open-Meteo (Free, No API Key Required)<\/li>\n<\/ul>\n<h2>\ud83d\udcc1 Project Structure Overview<\/h2>\n<p>Let\u2019s start by creating the necessary files for our temperature widget. Below is the directory structure we will be working with:<\/p>\n<pre>temperature-widget\/\r\n\u251c\u2500\u2500 index.html\r\n\u251c\u2500\u2500 script.js\r\n\u251c\u2500\u2500 weather.php\r\n\u2514\u2500\u2500 style.css\r\n<\/pre>\n<ol>\n<li><b>index.html<\/b>: This file will contain the HTML structure of the widget and link to the CSS and JavaScript files.<\/li>\n<li><b>style.css<\/b>: This file will contain the CSS styles to make the widget visually appealing and responsive.<\/li>\n<li><b>script.js<\/b>: This file will contain the JavaScript code to fetch weather data from the PHP backend and update the widget dynamically.<\/li>\n<li><b>weather.php<\/b>: This file will handle the server-side logic to fetch weather data from the Open-Meteo API based on the user&#8217;s location and return it as JSON.<\/li>\n<\/ol>\n<p><u>The widget will fetch weather data from the Open-Meteo API and display it in a user-friendly format. Below are the steps to create this widget:<\/u><\/p>\n<h2>Step 1: Create the HTML Structure (index.html)<\/h2>\n<p>First, we will create the basic HTML structure for our temperature widget. This will include a container for the widget, sections for the header, main content, and footer where we will display the weather information.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"temp-widget\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"widget-header\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"location\"<\/span>&gt;<\/span>Loading...<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"day-night\"<\/span>&gt;<\/span>\ud83c\udf1e<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"widget-main\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"temperature\"<\/span>&gt;<\/span>--<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">sup<\/span>&gt;<\/span>\u00b0C<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">sup<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"weather\"<\/span>&gt;<\/span>--<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"widget-footer\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"humidity\"<\/span>&gt;<\/span>Humidity: --%<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"datetime\"<\/span>&gt;<\/span>--<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">span<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span><\/pre>\n<p>Include JavaScript (<code>script.js<\/code>) to fetch and display weather data:<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"script.js\"<\/span>&gt;<\/span><span class=\"undefined\"><\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span><\/pre>\n<h2>Step 2: Style the Widget with CSS (style.css)<\/h2>\n<p>Next, we will add CSS styles to make our temperature widget visually appealing and responsive. We will use a clean and modern design with a color scheme that complements the weather data being displayed. The CSS will also ensure that the widget looks good on both desktop and mobile devices.<\/p>\n<pre style=\"color: rgb(68, 68, 68);\"><span class=\"hljs-selector-class\" style=\"color: rgb(136, 0, 0);\">.temp-widget<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">background<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">#ffffff<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">width<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">280px<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">padding<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">20px<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">border-radius<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">15px<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">box-shadow<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">0<\/span> <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">8px<\/span> <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">20px<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">rgba<\/span>(0,0,0,0.15);\r\n}\r\n\r\n<span class=\"hljs-selector-class\" style=\"color: rgb(136, 0, 0);\">.widget-header<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">display<\/span>: flex;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">justify-content<\/span>: space-between;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">font-weight<\/span>: bold;\r\n}\r\n\r\n<span class=\"hljs-selector-class\" style=\"color: rgb(136, 0, 0);\">.widget-main<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">text-align<\/span>: center;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">margin<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">20px<\/span> <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">0<\/span>;\r\n}\r\n\r\n<span class=\"hljs-selector-class\" style=\"color: rgb(136, 0, 0);\">.temperature<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">font-size<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">40px<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">font-weight<\/span>: bold;\r\n}\r\n\r\n<span class=\"hljs-selector-class\" style=\"color: rgb(136, 0, 0);\">.weather<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">display<\/span>: block;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">margin-top<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">5px<\/span>;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">color<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">#555<\/span>;\r\n}\r\n\r\n<span class=\"hljs-selector-class\" style=\"color: rgb(136, 0, 0);\">.widget-footer<\/span> {\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">display<\/span>: flex;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">justify-content<\/span>: space-between;\r\n    <span class=\"hljs-attribute\" style=\"font-weight: 700;\">font-size<\/span>: <span class=\"hljs-number\" style=\"color: rgb(136, 0, 0);\">14px<\/span>;\r\n}<\/pre>\n<h2>Step 3: Fetch and Display Weather Data with JavaScript (script.js)<\/h2>\n<p>Finally, we will write the JavaScript code to fetch weather data from our PHP backend (<code>weather.php<\/code>) and update the widget dynamically. The JavaScript will make an AJAX request to the PHP script, which will return the weather data in JSON format. We will then parse this data and update the HTML elements in our widget accordingly.<\/p>\n<pre style=\"color: rgb(68, 68, 68);\"><span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.addEventListener(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'DOMContentLoaded'<\/span>, () =&gt; {\r\n    fetch(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'weather.php'<\/span>)\r\n        .then(response =&gt; response.json())\r\n        .then(data =&gt; {\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.location'<\/span>).textContent = data.location || <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Unknown'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.temperature'<\/span>).innerHTML = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`<span class=\"hljs-subst\" style=\"color: rgb(68, 68, 68);\">${data.temperature ?? '--'}<\/span>&lt;sup&gt;\u00b0C&lt;\/sup&gt;`<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.weather'<\/span>).textContent = data.weather || <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'--'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.humidity'<\/span>).textContent = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">`Humidity: <span class=\"hljs-subst\" style=\"color: rgb(68, 68, 68);\">${data.humidity ?? '--'}<\/span>%`<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.datetime'<\/span>).textContent = data.datetime || <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'--'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.day-night'<\/span>).textContent = data.is_day ? <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'\ud83c\udf1e'<\/span> : <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'\ud83c\udf1c'<\/span>;\r\n        })\r\n        .catch(() =&gt; {\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.location'<\/span>).textContent = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Error'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.temperature'<\/span>).innerHTML = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'--&lt;sup&gt;\u00b0C&lt;\/sup&gt;'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.weather'<\/span>).textContent = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'--'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.humidity'<\/span>).textContent = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'Humidity: --%'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.datetime'<\/span>).textContent = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'--'<\/span>;\r\n            <span class=\"hljs-built_in\" style=\"color: rgb(57, 115, 0);\">document<\/span>.querySelector(<span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'.day-night'<\/span>).textContent = <span class=\"hljs-string\" style=\"color: rgb(136, 0, 0);\">'\u2753'<\/span>;\r\n        });\r\n});<\/pre>\n<h2>Step 4: Fetch Weather Data with PHP (weather.php)<\/h2>\n<p>In the <code>weather.php<\/code> file, we will write the PHP code to fetch weather data from the Open-Meteo API based on the user&#8217;s location. We will use the user&#8217;s IP address to determine their location and then make a request to the Open-Meteo API to retrieve the current weather data. Finally, we will return this data as JSON to be consumed by our JavaScript code in <code>script.js<\/code>.<\/p>\n<ul>\n<li>Auto-detect user location using IP address<\/li>\n<li>Fetch weather data from Open-Meteo API based on detected location<\/li>\n<li>Return weather data as JSON for frontend consumption<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Auto-detect&nbsp;IP&nbsp;address <br \/><\/span><span style=\"color: #0000BB\">$ip&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$_SERVER<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'REMOTE_ADDR'<\/span><span style=\"color: #007700\">]; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;location&nbsp;info&nbsp;from&nbsp;ip-api.com&nbsp;(free,&nbsp;no&nbsp;API&nbsp;key&nbsp;required) <br \/><\/span><span style=\"color: #0000BB\">$geo_url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"http:\/\/ip-api.com\/json\/<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$ip<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">?fields=status,message,country,regionName,city,lat,lon\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$geo_response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;@<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$geo_url<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$geo_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$geo_response&nbsp;<\/span><span style=\"color: #007700\">?&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$geo_response<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">)&nbsp;:&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/> <br \/>if&nbsp;(<\/span><span style=\"color: #0000BB\">$geo_data&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;<\/span><span style=\"color: #0000BB\">$geo_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">]&nbsp;===&nbsp;<\/span><span style=\"color: #DD0000\">'success'<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$lat&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$geo_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'lat'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$lon&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$geo_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'lon'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$location&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$geo_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'city'<\/span><span style=\"color: #007700\">]&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">',&nbsp;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$geo_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'country'<\/span><span style=\"color: #007700\">]; <br \/>}&nbsp;else&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Fallback&nbsp;to&nbsp;New&nbsp;York&nbsp;if&nbsp;geolocation&nbsp;fails <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$lat&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">40.7128<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$lon&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;-<\/span><span style=\"color: #0000BB\">74.0060<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$location&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'New&nbsp;York,&nbsp;USA'<\/span><span style=\"color: #007700\">; <br \/>} <br \/> <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Open-Meteo&nbsp;API&nbsp;(no&nbsp;API&nbsp;key&nbsp;required) <br \/><\/span><span style=\"color: #0000BB\">$weather_url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"https:\/\/api.open-meteo.com\/v1\/forecast?latitude=<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$lat<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&amp;longitude=<\/span><span style=\"color: #007700\">{<\/span><span style=\"color: #0000BB\">$lon<\/span><span style=\"color: #007700\">}<\/span><span style=\"color: #DD0000\">&amp;current_weather=true&amp;hourly=relative_humidity_2m,weathercode\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$weather_response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;@<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$weather_url<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #0000BB\">$weather_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_response&nbsp;<\/span><span style=\"color: #007700\">?&nbsp;<\/span><span style=\"color: #0000BB\">json_decode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$weather_response<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">)&nbsp;:&nbsp;<\/span><span style=\"color: #0000BB\">null<\/span><span style=\"color: #007700\">; <br \/> <br \/>if&nbsp;(<\/span><span style=\"color: #0000BB\">$weather_data&nbsp;<\/span><span style=\"color: #007700\">&amp;&amp;&nbsp;isset(<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'current_weather'<\/span><span style=\"color: #007700\">]))&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$temperature&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'current_weather'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'temperature'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$is_day&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'current_weather'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'is_day'<\/span><span style=\"color: #007700\">]&nbsp;==&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$datetime&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">date<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'l,&nbsp;H:i'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">strtotime<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'current_weather'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'time'<\/span><span style=\"color: #007700\">])); <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;humidity&nbsp;from&nbsp;hourly&nbsp;data&nbsp;(nearest&nbsp;hour) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$humidity&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'--'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(isset(<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'hourly'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'time'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;isset(<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'hourly'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'relative_humidity_2m'<\/span><span style=\"color: #007700\">]))&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$now&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'current_weather'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'time'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$idx&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">array_search<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$now<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'hourly'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'time'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">$idx&nbsp;<\/span><span style=\"color: #007700\">!==&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">)&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$humidity&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'hourly'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'relative_humidity_2m'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #0000BB\">$idx<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Weather&nbsp;description&nbsp;from&nbsp;weathercode <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$weather_codes&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;[ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">0&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Clear&nbsp;sky'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">1&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Mainly&nbsp;clear'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">2&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Partly&nbsp;cloudy'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">3&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Overcast'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">45&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Fog'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">48&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Depositing&nbsp;rime&nbsp;fog'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">51&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Light&nbsp;drizzle'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">53&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Drizzle'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">55&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Dense&nbsp;drizzle'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">56&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Freezing&nbsp;drizzle'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">57&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Dense&nbsp;freezing&nbsp;drizzle'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">61&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Slight&nbsp;rain'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">63&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Rain'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">65&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Heavy&nbsp;rain'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">66&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Freezing&nbsp;rain'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">67&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Heavy&nbsp;freezing&nbsp;rain'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">71&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Slight&nbsp;snow&nbsp;fall'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">73&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Snow&nbsp;fall'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">75&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Heavy&nbsp;snow&nbsp;fall'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">77&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Snow&nbsp;grains'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">80&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Slight&nbsp;rain&nbsp;showers'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">81&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Rain&nbsp;showers'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">82&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Violent&nbsp;rain&nbsp;showers'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">85&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Slight&nbsp;snow&nbsp;showers'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">86&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Heavy&nbsp;snow&nbsp;showers'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">95&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Thunderstorm'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">96&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Thunderstorm&nbsp;with&nbsp;hail'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">99&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Thunderstorm&nbsp;with&nbsp;heavy&nbsp;hail'<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$weathercode&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'current_weather'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'weathercode'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$weather&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$weather_codes<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">$weathercode<\/span><span style=\"color: #007700\">]&nbsp;??&nbsp;<\/span><span style=\"color: #DD0000\">'Unknown'<\/span><span style=\"color: #007700\">; <br \/>}&nbsp;else&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$temperature&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'--'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$weather&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Unavailable'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$humidity&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'--'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$is_day&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$datetime&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">date<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'l,&nbsp;H:i'<\/span><span style=\"color: #007700\">); <br \/>} <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Return&nbsp;data&nbsp;as&nbsp;JSON <br \/><\/span><span style=\"color: #0000BB\">header<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Content-Type:&nbsp;application\/json'<\/span><span style=\"color: #007700\">); <br \/>echo&nbsp;<\/span><span style=\"color: #0000BB\">json_encode<\/span><span style=\"color: #007700\">([ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'location'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$location<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'temperature'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$temperature<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'weather'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$weather<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'humidity'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$humidity<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'is_day'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$is_day<\/span><span style=\"color: #007700\">, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'datetime'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$datetime <br \/><\/span><span style=\"color: #007700\">]); <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>\ud83c\udfaf Final Output<\/h2>\n<p>Once you have completed the above steps, your temperature widget should be fully functional and display real-time weather information based on the user&#8217;s location. The widget will show the current temperature, weather description, humidity, date &#038; time, and a day\/night indicator icon.<\/p>\n<ul>\n<li>\ud83c\udf21\ufe0f Current temperature (\u00b0C)<\/li>\n<li>\ud83d\udccd Auto-detected city &#038; country<\/li>\n<li>\ud83c\udf24 Weather condition<\/li>\n<li>\ud83d\udca7 Humidity<\/li>\n<li>\ud83d\udd52 Date &#038; time<\/li>\n<li>\ud83c\udf1e\/\ud83c\udf1c Day or Night indicator<\/li>\n<\/ul>\n<p>All fully dynamic and automatic.<\/p>\n<h2>\ud83d\udccc Use Cases of Weather Widget<\/h2>\n<ul>\n<li><b>Personal Blogs:<\/b> Display local weather conditions to enhance user engagement.<\/li>\n<li><b>Travel Websites:<\/b> Show current weather at popular destinations to help travelers plan their trips.<\/li>\n<li><b>News Portals:<\/b> Provide real-time weather updates alongside news articles.<\/li>\n<li><b>Event Pages:<\/b> Inform attendees about the weather forecast for outdoor events.<\/li>\n<\/ul>\n<h2>\ud83d\ude80 Conclusion<\/h2>\n<p>In this tutorial, we have successfully created a real-time temperature widget using JavaScript and PHP. This widget automatically detects the user&#8217;s location, fetches live weather data from the Open-Meteo API, and displays it in a visually appealing format. You can easily customize the design and functionality of the widget to suit your website&#8217;s needs. This is a great way to enhance user experience by providing relevant and timely information. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to display real-time temperature, humidity, weather description, and day\/night status on your website, this tutorial will help you build a fully functional Temperature Widget using JavaScript and PHP. This widget: \u2714 Detects <\/p>\n","protected":false},"author":1,"featured_media":6055,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[400,66,398,14,397,399],"class_list":["post-6049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-ip-address","tag-javascript","tag-open-meteo-api","tag-php","tag-temperature-widget","tag-weather","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API) - CodexWorld<\/title>\n<meta name=\"description\" content=\"Create a real-time temperature widget using JavaScript and PHP with auto IP detection and Open-Meteo API integration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API) - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Create a real-time temperature widget using JavaScript and PHP with auto IP detection and Open-Meteo API integration.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-21T09:17:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-21T09:47:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API)\",\"datePublished\":\"2026-02-21T09:17:37+00:00\",\"dateModified\":\"2026-02-21T09:47:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/\"},\"wordCount\":727,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg\",\"keywords\":[\"IP Address\",\"JavaScript\",\"Open-Meteo API\",\"PHP\",\"Temperature Widget\",\"Weather\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/\",\"name\":\"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API) - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg\",\"datePublished\":\"2026-02-21T09:17:37+00:00\",\"dateModified\":\"2026-02-21T09:47:53+00:00\",\"description\":\"Create a real-time temperature widget using JavaScript and PHP with auto IP detection and Open-Meteo API integration.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2026\\\/02\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg\",\"width\":1536,\"height\":1024,\"caption\":\"create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API) - CodexWorld","description":"Create a real-time temperature widget using JavaScript and PHP with auto IP detection and Open-Meteo API integration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/","og_locale":"en_US","og_type":"article","og_title":"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API) - CodexWorld","og_description":"Create a real-time temperature widget using JavaScript and PHP with auto IP detection and Open-Meteo API integration.","og_url":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2026-02-21T09:17:37+00:00","article_modified_time":"2026-02-21T09:47:53+00:00","og_image":[{"width":1536,"height":1024,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg","type":"image\/jpeg"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API)","datePublished":"2026-02-21T09:17:37+00:00","dateModified":"2026-02-21T09:47:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/"},"wordCount":727,"commentCount":0,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg","keywords":["IP Address","JavaScript","Open-Meteo API","PHP","Temperature Widget","Weather"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/","url":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/","name":"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API) - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg","datePublished":"2026-02-21T09:17:37+00:00","dateModified":"2026-02-21T09:47:53+00:00","description":"Create a real-time temperature widget using JavaScript and PHP with auto IP detection and Open-Meteo API integration.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg","width":1536,"height":1024,"caption":"create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Create a Temperature Widget using JavaScript and PHP (Auto Location + Live Weather API)"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2026\/02\/create-temperature-widget-using-javascript-php-auto-location-live-weather-api-codexworld.jpg","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-1zz","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/6049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=6049"}],"version-history":[{"count":5,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/6049\/revisions"}],"predecessor-version":[{"id":6054,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/6049\/revisions\/6054"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/6055"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=6049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=6049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=6049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}