Advertisement
Riekelt

Imperial to Metric time calculator

Oct 5th, 2023
1,142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pbTime = "2:24:26"
  2. var pbSeconds;
  3. pbSeconds = timeToSeconds(pbTime);
  4.  
  5. pbSeconds = pbSeconds * (100000/86400);
  6. console.log(pbSeconds);
  7.  
  8. function timeToSeconds(timeString) {
  9.   const timeParts = timeString.split(":");
  10.   const hours = parseInt(timeParts[0], 10);
  11.   const minutes = parseInt(timeParts[1], 10);
  12.   const seconds = parseInt(timeParts[2], 10);
  13.  
  14.   // Calculate the total seconds
  15.   const totalSeconds = hours * 3600 + minutes * 60 + seconds;
  16.  
  17.   return totalSeconds;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement