Skip to content

Durations: Convert HH:MM:SS string to seconds  #1146

Description

@hamzahamidi

Describe the bug
A clear and concise description of what the bug is.
I just wanted to know if it's possible with Dayjs to Convert HH:MM:SS string to seconds. and if it's not possible would you consider implementing this feature? (I'm available for this feature)

The feature can be used like this:

  const duration = dayjs.duration( '02:04:33', 'HH:mm:ss');

and the function would return something like the following:

const d = '02:04:33';   // your input string
const a = hms.split(':'); // split it at the colons

const result = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]); 
console.log(result);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions