“JS Days to Hours” Kode Jawaban

cara mengubah detik menjadi detik detik js

function secondsToDhms(seconds) {
seconds = Number(seconds);
var d = Math.floor(seconds / (3600*24));
var h = Math.floor(seconds % (3600*24) / 3600);
var m = Math.floor(seconds % 3600 / 60);
var s = Math.floor(seconds % 60);

var dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : "";
var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
return dDisplay + hDisplay + mDisplay + sDisplay;
}
Grumpy Gaur

JS Days to Hours

var days = parseInt(prompt("Please enter days:"));
var hours = days * 24;
console.log(hours + " Hours");

//Output:
Please enter days: 20
480 Hours
Enchanting Echidna

Jawaban yang mirip dengan “JS Days to Hours”

Pertanyaan yang mirip dengan “JS Days to Hours”

Lebih banyak jawaban terkait untuk “JS Days to Hours” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya