Ich habe ein JavaScript-Timing-Event mit einer Endlosschleife mit Stop-Taste.Sekunden in Tage, Stunden, Minuten und Sekunden umrechnen
Es wird Zahlen angezeigt, wenn Start-Taste ist click.Now ich diese Zahlen etwas wie 4 Stunden, 3 Minuten umgewandelt wollen, 50 Sekunden
html
<p class="start">Start</p>
<p class="end">End</p>
<p class="hide_div">
<input type="text" id="txt" />//display numbers eg 12345
</p>
css
.hide_div {
display: none;
}
.end {
display: none;
}
js
<script>
$(".start").on("click", function() {
//var start = $.now();
//alert(start);
//console.log(start);
doTimer();
$(".end").show();
$(".hide_div").show();
});
$(".end").on("click", function() {
stopCount();
});
</script>
<script>
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout(function(){timedCount()},1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
Wie konvertiert man Zahlen wie 123456 in 1 Tag, 4 Stunden, 40 Minuten, 45 Sekunden?
Sie gelöst sein würden ? – C2486