How we can format the duration in dayjs.
See original GitHub issueI have tried o use this but it does not work
import dayjs from 'dayjs';
import duration from 'dayjs/plugin/duration';
dayjs.extend(duration);
const toTimeFormat = (milliseconds: number) => {
return dayjs.duration(milliseconds).format('HH:mm:ss')
};
Issue Analytics
- State:
- Created 3 years ago
- Reactions:18
- Comments:20 (6 by maintainers)
Top Results From Across the Web
Format
Get the formatted duration according to the string of tokens passed in. ... dayjs.duration({ seconds: 1, minutes: 2, hours: 3, days: 4, months:...
Read more >Dayjs: Any workaround for format duration in h m
Seems the library converts the 24hrs to 1 day and puts the remaining 1 hour in hours. Actually, I want the output as...
Read more >How to use the dayjs.duration function in dayjs - Snyk
To help you get started, we've selected a few dayjs examples, based on popular ways it is used in public projects. ; data)...
Read more >date and time in JavaScript with Day.js - ZetCode
Day.js is a minimalist JavaScript date library for parsing, validating, manipulating, and formatting dates. It is an alternative library to ...
Read more >The Complete Guide to Day.js - Mirza Leka - Medium
Custom Parse Format extends dayjs() the constructor to support custom formats of input strings. Basically, it allows us to pass the date format...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi! can we remove zero values from formatted result? for example -
dayjs.duration(1500, 'seconds').format('H[h] m[m] s[s]')gives
0h 25m 0sI’d like it to be just
25mWe need it too.