How to use moment.js in Vue.js and Laravel 5
In this project I wanted to show when how old the post was since I uploaded it. To do this I wanted to use the very popular package moment.js. Here is the process.NPM
npm install moment
Vue.js Component
Above you export and below the script tag import moment. Then add moment as a variable in the return attribute.//Above the export and below the script open tag
var moment = require('moment');
//in the data return add
moment: moment
Now to use moment you simply do this within the componentmoment(post.created_at).fromNow()
You can view this on YouTube
Categories: Posts