Javascript parsing Times without Date

后端 未结 5 2031
轻奢々
轻奢々 2020-12-08 18:22

I need to parse and manipulate Times without Dates in my code. For example i might get the string \"15:00\" from a timepicker. I want to turn this into a Time object of some

5条回答
  •  死守一世寂寞
    2020-12-08 18:51

    Okay, so I know I'm way late to the party. Like 6 years late but this was something I needed to figure out and have it formatted HH:mm:ss (24 hours).

    moment().format(moment.HTML5_FMT.TIME_SECONDS); // 17:44:56
    

    You can also pass in a parameter like, 2019-11-08T17:44:56.144.

    moment('2019-11-08T17:44:56.144').format(moment.HTML5_FMT.TIME_SECONDS); // 17:44:56
    

    https://momentjs.com/docs/#/parsing/special-formats/

提交回复
热议问题