Creating filters in Vue Js

As much as I love Angular, I had to switch to Vue js.

Angular has most of the pipes/filters built into it and Vue js is not, So I had to write my own pipe to format the date.¬† My Vue Js project is in TypeScript (yeah I know, typical .net dev’s choice ;))

create a folder called filters in the root of the app and create a file called formatdate.ts, below is the code for the filter.

now you need to make it available globally, therefore need to import it into the main file – which is app.vue

Now you can use it anywhere in the app like this.


Leave a comment