javascript - Convert integers to time and add -


i have requirement converting integer value time format using javascript.

my requirement result should in time format.

example 08:55 , 09:55

if add these 2 numbers 18.10 need 18:50

try this: (my solution assumes sum of times not more 24 hours)

function pad(str) {      return ("00"+str).slice(-2); }  var str1 = "08:55"; var str2 = "09:55"; var token1 = str1.split(":"); var token2 = str2.split(":"); var result = token1[0] * 60 + + token1[1] + + token2[0] * 60 + + token2[1]; var newtime = pad(math.floor(result/60)) + ":" + pad(result % 60); console.log(newtime); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -