My weather app was displaying the time correctly only when getMinutes() was greater than 10, but if the clock displayed 1:02 pm my weather app would display 1:2 so, I fixed that issue with the code below.
$.getJSON(url, function(data) {
$("#location").html("Location: " + data.name + ", " + data.sys.country);
var myDate = new Date();
$("#localtime").html("Time: " + myDate.getHours() + ":" + '0' + myDate.getMinutes()).slice(-2);
However, my code created a different problem for me. Now if the clocked says that it’s 1:12pm, my weather app will display it as 1:012pm. Any suggestions on how to fix this issue?