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.

firebaseのTimestamp型の日付をnuxtで表示する

Last updated at Posted at 2021-09-19

firebaseからデータ取得するとtimestamp型で帰ってくるので2021/1/11 00:00:00の形式に変換します。
絶対わすれるのでメモ

index.vue
<div v-for="comment in comments" :key="comment[0]">
    <div>{{ comment[1].name }}</div>
    <div>{{ comment[1].comment }}</div>
    <div>{{ postedDay(comment[1].posted) }}</div>
</div>

  methods: {
    postedDay (timestamp) {
      return (
        timestamp.toDate().toLocaleString('ja-JP')
      )
    }
  }

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?