Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to convert seconds into days hours seconds 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;
}
Comment

how to convert seconds in hours minutes and seconds js

function convertSeconds(seconds) {
  var convert = function(x) { return (x < 10) ? "0"+x : x; }
  return convert(parseInt(seconds / (60*60))) + ":" +
         convert(parseInt(seconds / 60 % 60)) + ":" +
         convert(seconds % 60)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js cooldown 
Javascript :: set width screen angular 
Javascript :: axios delete is throwing cors error 
Javascript :: uninstall node js from mac 
Javascript :: javascript update attribute 
Javascript :: domain regex 
Javascript :: submit form through jquery by id 
Javascript :: react native android build apk 
Javascript :: jspdf text align center 
Javascript :: how to resolve @fortawesome/free-solid-svg-icons in react 
Javascript :: kill node process windows 
Javascript :: how to remove https link from javascript 
Javascript :: hello world javascript 
Javascript :: how to get the first character of a string in javascript 
Javascript :: node read file line 
Javascript :: a-z array javascript 
Javascript :: how to submit using checkbox 
Javascript :: write in utf8 fs 
Javascript :: remove last character from string js 
Javascript :: clear ctx canvas with javascript 
Javascript :: javascript base64 encode 
Javascript :: reactnavigation 5 hide header 
Javascript :: js pi 
Javascript :: how to insalk react router with npm 
Javascript :: vue.js use scss in balise style 
Javascript :: horizontal divider react native 
Javascript :: javascript dom id selector 
Javascript :: javascript change webpage title 
Javascript :: javascript innerhtml table 
Javascript :: yarn create strapi-app 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =