私は時間を操作するためにmomentjsを使用しています。私は時、分、'00:30:00 'のような2番目の文字列を持っています。そして、私はそれに数分を追加したいと思います。私はこの文字列を数分に変換することができますし、私が望む時間を簡単に追加することができます。しかし、私はどのようにそれを刺すように戻すのですか?時間文字列に分を追加する方法は?
ex - moment.duration('00:30:00 ')。asMinutes;私に分を与えるでしょう。 これが30になると仮定すると、30分を追加して60分にすることができます。 momentjsを使用してこの文字列に60分を再度変換するにはどうすればよいですか?
console.log(moment.duration('00:30:00').add(30, 'minutes'));
を印刷するには、私はあなたが.add
を使用する必要があります
[object Object] { _bubble: function Zc(){var a,b,c,d,e,f=this._milliseconds,g=this._days,h=this._months,i=this._data;
// if we have a mix of positive and negative values, bubble down first
// check: https://github.com/moment/moment/issues/2166
// The following code bubbles up values, see the tests for
// examples of what that means.
// convert days to months
// 12 months -> 1 year
return f>=0&&g>=0&&h>=0||0>=f&&0>=g&&0>=h||(f+=864e5*Yc(_c(h)+g),g=0,h=0),i.milliseconds=f%1e3,a=s(f/1e3),i.seconds=a%60,b=s(a/60),i.minutes=b%60,c=s(b/60),i.hours=c%24,g+=s(c/24),e=s($c(g)),h+=e,g-=Yc(_c(e)),d=s(h/12),h%=12,i.days=g,i.months=h,i.years=d,this},
.... continued
これは私に別のものを与えています。一度試してみることができます – scripter
@scripter試した内容とエラーメッセージ全体を編集してください。 –
私はそれを更新しました。 – scripter