0

Hi I'm current trying to convert a timestamp into MM:SS or just into second using momentjs. The format of the timestamp looks like "2021-02-13T23:56:03.887386+00:00". Im pretty new to momentjs, I'm wondering if there is anyway to convert this timestamp into minutes:seconds or just into seconds. I tried using moment("2021-02-13T23:56:03.887386+00:00").valueOf(), this gave me a value of 1613260563887, Im not sure what is this value is. Can anyone please explain this a little bit? Much appreciated.

user14459580
  • 206
  • 2
  • 12
  • Please indicate what value you would expect to see when you "convert a timestamp into MM:SS." I.e., what is the original timestamp you wish to "convert," and what would the converted output look like? – Marc Feb 16 '21 at 22:08
  • So is it possible to convert `"2021-02-13T23:56:03.887386+00:00"` into "56:03" something like that? – user14459580 Feb 16 '21 at 22:13
  • https://momentjs.com/docs/#/displaying/format/ – cbr Feb 16 '21 at 22:16

1 Answers1

1

Use moment("2021-02-13T23:56:03.887386+00:00").format("mm:ss") to show only the minute and seconds.

As mentioned by @cbr see moment docs for more formatting details

Shmili Breuer
  • 3,927
  • 2
  • 17
  • 26
  • I see thanks a lot, do you know what the output value from `moment("2021-02-13T23:56:03.887386+00:00").valueOf()` means? the output is `1613260563887`, is this epoch time? – user14459580 Feb 16 '21 at 22:19
  • 1
    It gives oyu the unix time see https://www.geeksforgeeks.org/moment-js-moment-valueof-function/ Also see https://stackoverflow.com/a/25509485/3161811 – Shmili Breuer Feb 16 '21 at 22:21