how do I add two time values together, for example it needs to be able to add 25 hours and 3 days together | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how do I add two time values together, for example it needs to be able to add 25 hours and 3 days together

In a javascript function how do I add two time values together, for example it needs to be able to add 25 hours and 3 days together. It can be called for instance by: timeAdder(5,"days",25,"hours")

28th Jun 2020, 9:12 PM
RKD
RKD - avatar
1 Answer
+ 2
Depending on the format of the output: You can convert everything into the smallest unit of time (you will get 25+72 =97 hours .. or use modulo operator to get back to day+hours eg "4 days and 1hour".
28th Jun 2020, 10:36 PM
ifl
ifl - avatar