0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

moment.jsのsubtract(減算)で時間の分(m)がうまく行かなかった件

Last updated at Posted at 2020-01-23

問題定義

moment.jsで30分減算した時間を出したかったが subtract(int, 'm') でブラウザがフリーズした

import moment from 'moment'
const time = moment('22:00', 'HH:mm');
// これを実装するとブラウザが固まる
const reducedTime = time.subtract(30, 'm');

解決

subtract(int, 'm')subtract(int, 'minutes')に変えると解決した

import moment from 'moment'
const time = moment('22:00', 'HH:mm');
// これを実装するとブラウザが固まる
const reducedTime = time.subtract(30, 'minutes');

コメント

なぜかはわからないので原因がわかる方はコメントで教えてくださると嬉しいです。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?