Ich habe eine digitale Uhr auf meiner Seite mit Javascript erstellt und möchte sie von der Militärzeit in die Standardzeit ändern. Ich will nur, dass es auch die Stunden und Minuten anzeigt. Was soll ich tun, um dies zu implementieren?Wie ändere ich meine Javascript-Digitaluhr von Militärzeit auf Standardzeit?
body {
background-color: black;
margin-left: 5%;
margin-right: 5%;
}
#txt {
color: white;
float: left;
font-family: OpenSans;
font-size: 90px;
margin: 20px;
}
#weather {
color: white;
float: right;
font-family: OpenSans;
font-size: 40px;
margin: 20px;
}
<!DOCTYPE html>
<html>
<head>
<title>Blooming Time And Temperature</title>
<link href="css/format.css" rel="stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="js/jquery.simpleWeather.min.js"></script>
<script>
$(document).ready(function() {
$.simpleWeather({
location: 'Brooklyn, NY',
woeid: '',
unit: 'f',
success: function(weather) {
html = '<p>'+weather.temp+'°'+weather.units.temp+'</p>';
html += '<div id="city">'+weather.city+', '+weather.region+'</div>';
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
});
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
<div id="weather"></div>
</body>
</html>
'if (h> 12) h = h-12;' – j08691
was etwa 0 :) –
Es tut mir leid, Jungs, ich bin völlig neu zu Javascript und mein Professor nur hat uns diese Uhraufgabe als eine Woche Übung gegeben, ich weiß nicht, worauf man sich bezieht oder was ihr leider meint. :( –