0

I try to convert the '00:00:00', to 0 seconds on UI with React intl.

<MenuItem 
  value='00:00:00'
  primaryText={
    <FormattedTime 
      second='numeric' 
      units='second'
      value={new Date(2012, 11, 20, 3, 0, 0)}
    />
  }
/>

How to show on UI '0 seconds'

Siya Mzam
  • 4,655
  • 1
  • 26
  • 44
Palaniichuk Dmytro
  • 2,943
  • 12
  • 36
  • 66

1 Answers1

0

To convert "00:00:00" into just "0", you can do:

value={parseInt('00:00:00'.substring(6)) + " seconds"}

The above will take the last 00, which are the seconds, convert it into an integer (to remove any leading zeroes) and then appends the string " seconds".

Chris
  • 57,622
  • 19
  • 111
  • 137
  • Yes I can even use `${parseInt('00:00:00'.substring(6))}seconds`, I'm thought that by React intl can use Intl.DateTimeFormat API and show the second automatically – Palaniichuk Dmytro Nov 10 '17 at 10:10