When I use:
console.log(moment(1000*60*60*1).format('hh[h] mm[min] ss[sec]'));
I get 2h 0min 0sec instead of just 1hour.
I made a workaround by adding .subtract(1, 'hour') like this:
console.log(moment(1000*60*60*1).subtract(1, 'hour').format('hh[h] mm[min] ss[sec]'));
I'm still learning this library that i found today. Am I missing something?
What am I supposed to do if I have milliseconds and I want to get a formatted date out of it?
Moment counts your timezone, to get the time without timezone offset you can use
moment(1000*60*60*1).utc().format('hh[h] mm[min] ss[sec]')
Or
moment.utc(1000*60*60*1).format('hh[h] mm[min] ss[sec]')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With