Reputation: 2127
I've got an hour in a string format like this : 14:00:00.000 I want to convert it in a nicer format : 14h
I try to use react-moment for this, with
<Moment format="hh:mm:ss.a">"14:00:00.000"</Moment>
But it doesn't work. Any good practice?
Upvotes: 3
Views: 2128
Reputation: 1050
momentjs
is in legacy state and explained in detail in the project status page.
Their recommended alternative is Luxon.
To format it like you have specified, simply use the toFormat() method. Included in that link is a list of tokens you can use to help format it to exactly how you'd like it.
The following formats it like you have asked: 14h
DateTime.now().toFormat("HH'h'")
Upvotes: 7