const formatSeconds = (s: number) => {
        const [hour, minute, second, sign] =
          s > 0
            ? [s / 3600, (s / 60) % 60, s % 60, '']
            : [-s / 3600, (-s / 60) % 60, -s % 60, '-'];
        return (
          sign +
          [hour, minute, second]
            .map(v => `${Math.floor(v)}`.padStart(2, '0'))
            .join(':')
        );
      };
      
      Typescript language logo

      Seconds to ISO

      Codiga's TypeScript Recipes

      Returns the ISO format of the given number of seconds.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.