Simple date parsing filter for Vue.js
install from npm
$ npm install @vuejs-community/vue-filter-date-parse
and register in you Vue app
import Vue from 'vue';
import VueFilterDateParse from '@vuejs-community/vue-filter-date-parse';
Vue.use(VueFilterDateParse);
Using with dateFormat filter:
<template>
<div>{{ '15.05.1967' | dateParse('DD.MM.YYYY') | dateFormat('YYYY-MM-DD') }}</div>
</template>
or
<template>
<div>{{ '15.05.67' | dateParse('DD.MM.YY', { epoch: 1900 }) | dateFormat('YYYY-MM-DD') }}</div>
</template>
render as:
<div>1967-05-15</div>
Key | Input | |
---|---|---|
Year | YYYY |
2000 2001 ... 2029 2030 |
YY |
00 01 ... 29 30 | |
Month | MM |
01 02 ... 11 12 |
Day | DD |
01 02 ... 30 31 |
Hour | HH |
00 01 ... 22 23 |
Minute | mm |
00 01 ... 58 59 |
Second | ss |
00 01 ... 58 59 |
Default format is YYYY-MM-DD HH:mm:ss
MIT © Vue.js Community