react-moment icon indicating copy to clipboard operation
react-moment copied to clipboard

How do I set format for durationFromNow?

Open gusoskar opened this issue 5 years ago • 2 comments

I'm trying to set a format for the duration time, but I am unable to do so. The default format seems to be mm:ss, but I'd like to change that to (HH:mm:ss).

This is what I tried to do: <Moment element={Text} date={this.props.start} format="HH:mm:ss" durationFromNow unix />

This only return the this.props.start (unix time) formatted as HH:mm:ss and seems to forget about the durationFromNow.

I also tried <Moment element={Text} date={this.props.start} format="mm:ss" durationFromNow unix />

This returns 1,798:00

gusoskar avatar Feb 28 '19 12:02 gusoskar

I also wonder how

const now = new Date()
...
<Moment date={now} durationFromNow interval={1000} />

This returns x milliseconds before the first second has passed =/

Annihil avatar Mar 15 '19 13:03 Annihil

@Annihil me too. I would assume that +/- 0.5 seconds are just 0 seconds. And all above is one second and so on.

encbladexp avatar Mar 16 '19 12:03 encbladexp