How to do it...

Let's say we are curating an interactive page to learn history. We have our Vue instance with the following JavaScript code:

new Vue({   el:'#app',   data: {     bastilleStormingDate: '1789-07-14 17 h'   } })

In our data, we have a date written informally as a string in our instance data. Our HTML can contain a timeline of the French Revolution and, at some point, can contain the following:

<div id="app">   The Storming of the Bastille, happened on {{bastilleStormingDate | date}} </div>

We need a filter capable of completing the sentence. For this, one possible library is the excellent moment.js and, for our purposes, we'll choose the localized version: https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.js ...

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.