[+] Format date with moment

This commit is contained in:
Hykilpikonna
2021-12-05 01:25:34 -05:00
parent 20d22c3271
commit 186239cff2
2 changed files with 4 additions and 0 deletions
+1
View File
@@ -9,6 +9,7 @@
}, },
"dependencies": { "dependencies": {
"core-js": "^3.6.5", "core-js": "^3.6.5",
"moment": "^2.29.1",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-class-component": "^8.0.0-0", "vue-class-component": "^8.0.0-0",
"vue-i18n": "^9.2.0-beta.23", "vue-i18n": "^9.2.0-beta.23",
+3
View File
@@ -19,6 +19,7 @@
<script lang="ts"> <script lang="ts">
import {Options, Vue} from 'vue-class-component'; import {Options, Vue} from 'vue-class-component';
import {backendUrl} from "@/constants"; import {backendUrl} from "@/constants";
import moment from "moment";
export interface Post { export interface Post {
id: string id: string
@@ -53,6 +54,8 @@ export default class Blog extends Vue
{ {
fetch(`${backendUrl}/posts.json`).then(it => it.json()).then(it => { fetch(`${backendUrl}/posts.json`).then(it => it.json()).then(it => {
this.posts = it this.posts = it
this.posts.forEach(it => it.date = moment(it.date).format('YYYY-MM-DD h:mm'))
this.posts.reverse()
console.log(it) console.log(it)
}) })
} }