LoginSignup
1
2

More than 1 year has passed since last update.

【Vue】day.jsを使って時間を表示する。

Posted at

day.jsとは

ずばり日付に関するライブラリです。

day.jsの導入方法

以下のnpm、yarnを使ってインストールします。

  • npm
npm install dayjs --save
  • yarn
yarn add dayjs

導入手順

1.ライブラリの取り込み

import dayjs from "dayjs";

dayjs.locale("ja");
Vue.prototype.$dayjs = dayjs;

2.テンプレートを準備

<div class="mytime">{{ $dayjs(time).format("hh:mm") }}</div>

細かく日時を設定したい場合

公式リファレンスを参照してください。

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