pKay
pKay

Reputation: 1840

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

Upvotes: 4

Views: 7174

Answers (2)

pKay
pKay

Reputation: 1840

Duration.fromMillis(150000).toFormat("mm'm' ss's'")

Upvotes: 8

rafalimaz
rafalimaz

Reputation: 80

@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

Upvotes: 2

Related Questions