0

Is anyone aware of a library I can use in React that converts locale aware time interval to either Date interval or a number (e.g., a number of seconds). For instance:

"2min" -> 120
"2 minutes" -> 120
"2 Minuten" -> 120 (locale: de)

and so on.

Can do it myself of course, but feels like a thing that someone has already done before...

PS. I am using date-fns to do the opposite conversion.

Vlad Z
  • 383
  • 2
  • 12

1 Answers1

1

you can use the following function:

 function localSekundenConvert(timeInString){
 const splitTime = timeInString.toLowerCase().split('m');
 const minuten = splitTime[0];
 const sekunden=minuten*60
 const formatSekunden=`${sekunden} sekunden`
 console.log(formatSekunden)
 return formatSekunden;
  }

 localSekundenConvert("33 minuten")