1
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 1 year has passed since last update.

【JS】Day.jsのformatがすごい!! (m:ss表記にもできちゃう)

Posted at

動画の再生時間を表示させたいって時に、Day.jsのformatが便利だったので紹介する。

まずは、import

import dayjs, { extend } from 'dayjs';
import duration from 'dayjs/plugin/duration';

extend(duration);

期間を扱うプラグイン duration をインポートします。
extend(duration); で dayjs がプラグインを使えるように登録します。

で「m:ss」表記にする場合は以下のように記述する。

const number = 61
dayjs.duration(number, 'second').format('m:ss') //1:01
1
0
0

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
1
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?