Every time I try to
---- make changes ----
var someMoment = moment('6:30 PM', ["h:mm A"]);
---- end changes ----
someMoment.add(30, 'minutes')
I am not getting any desired outcome.
console.log(start); -- Moment {_isAMomentObject: true, _i: "6:30 PM", _f: "h:mm A", _isUTC: false, _pf: Object…}
console.log(start.add(inc, 'minutes')); --Moment {_isAMomentObject: true, _i: "6:30 PM", _f: "h:mm A", _isUTC: false, _pf: Object…}
According to the documentation, the add function should modify the specified moment, so the above code should work, but I have also attempted
var end = start.add(inc, 'minutes')
console.log(end); --Moment {_isAMomentObject: true, _i: "6:30 PM", _f: "h:mm A", _isUTC: false, _pf: Object…}
what I can do though is this
console.log(start.add(inc, 'minutes').format("h:mm A")); --7:00 PM
My goal is to take a moment, add 30 minutes to it and, preferably have a new moment that is 30 minutes ahead, or at least have the initial moment be 30 minutes ahead.
I know I can take the format output and create a new moment, and I might have to do that, but this seems somewhat flawed.
---- make changes ----
using moment 2.1
I am experiencing this issue within a method in my application, I haven't isolated it in a jsfiddle or anything, but the method takes a string and an increment. I suppose I'll paste it here
here i'm trying one way but I've also tried using the modified start and cloning the start
var timeIsBetweenStartInc = function(_target:string, _start:string, inc:int){
var target = moment(_target, ["h:mm A"]);
var start = moment(_start, ["h:mm A"]);
console.log(start);
var end = moment(start).add(inc, 'minutes');
console.log(end);
return target.isBetween(start, end, 'minutes', '[)');(target, start, end);
};
---- end changes ----