Hi there! I am the creator of the moment plugin "moment-weekdaysin" (https://github.com/kodie/moment-weekdaysin) and back in July I tried to submit it to the moment website however @maggiepint had a few concerns and denied the request suggesting that I get on here to get some advice. moment/momentjs.com#439
So I was just wondering what you guys recommend I change in my plugin. Thank you!
Hey guys
I have a weird issue
I have a string ISO date, lets call it startTime
I also have a duration string, in the format of 'HH:mm:ss'
I need to calculate the endTime as startTime + duration
I am trying to do this like this:
const endTime = moment(startTime).add(moment.duration(duration))
moment('201206130139', 'YYYYMMDDHHmm')
worked... i was using MM
because i haven't had enough coffee
moment('2024-12').endOf('month').format('W')
moment('2024-12').endOf('month').add(-12, 'hours').format('W')
Both of these result to 1. Why? It must be something like 52.
require('moment')
while the test used require('moment-timezone')
moment().tz('Europe/Oslo').add(1, 'year').month(2).endOf('month')
.weekday(0)
The docs say the following:
Note: if you chain multiple actions to construct a date, you should start from a year, then a month, then a day etc. Otherwise you may get unexpected results, like when day=31 and current month has only 30 days (the same applies to native JavaScript Date manipulation), the returned date will be the 30th of the current month (see month for more details).
Bad: moment().date(day).month(month).year(year)
Good: moment().year(year).month(month).date(day)
Based on that information I would expect:moment().year(2018).month(3).date(31).format()
To print: "2018-04-30T13:20:40-04:00”
But instead it prints: "2018-05-01T13:20:40-04:00”
Why?
.isAfter()
method that I'd like to confirm is unexpected before I make a bug report. It looks like the comparison with day-granularity (moment1.isAfter(moment2, 'day')
) depends upon the locale of moment1
to determine if the day number is equal.
moment(new Date('2018-07-03T03:00:00.000Z')).isAfter(new Date('2018-07-03T00:00:00.000Z'), 'day') //false