'How to convert milliseconds to minutes using luxon library
I want to perform a transformation using luxon from milliseconds to minutes.
For eg. if i enter 1000 , te output should be 1m 0s.
I am trying Duration.fromMillis(1000).as('minutes') but in return i am getting 0 output. Is there any other way i can achieve the same thing
Solution 1:[1]
Duration.fromMillis(150000).toFormat("mm'm' ss's'")
Solution 2:[2]
@snickersnack comment should be accepted as answer, as it states a very useful way to play with luxon:
Duration.fromMillis(4515000).shiftTo("hours","minutes","seconds").toObject()
Will create an object:
{ hours: 1, minutes: 15, seconds: 15 }
Than you can do what you need
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pKay |
| Solution 2 | rafalimaz |
