I'd like to convert Float to X hours XX minutes or less in Javacript.
1.2=>"1 hour and 12 minutes"
1.211=>"1 hour and 12 minutes"
1.11=>"1 hour 06 minutes"
1.8=>"1 hour 48 minutes"
1.89=>"1 hour 53 minutes"
Does such a library exist?
Or do I need to implement it myself?
Suppose the variable f
contains such a value.
`${Math.floor(f)} hours ${(Math.floor(f*60)%60).toString().padStart(2,'0')} minutes`
I think it's okay to do that.
© 2024 OneMinuteCode. All rights reserved.