I have a date format of 19 Oct 2017 and want to convert it to this format 20171019
Is there a quick way of doing this? I am using FlatPickr in VueJs. Please find my code below if its any help.
import flatPickr from 'vue-flatpickr-component';
import 'flatpickr/dist/flatpickr.css';
import Navigation from './Navigation'
import bus from '../bus'
export default {
data() {
return {
showPanel: false,
isClosed: false,
arrival: null,
departure: null,
config: {
dateFormat: "Ymd"
}
}
},
components: {
flatPickr
},
methods: {
closeMenu: function() {
this.$store.state.showBooking = false;
}
},
mounted() {
bus.$on('show-booking', () => {
this.showPanel = true;
})
}
}
解决方案
You can do this easily:
import moment from 'moment'
methods: {
format_date(value){
if (value) {
return moment(String(value)).format('YYYYMMDD')
}
},
},
Then:
format_date(date)