Wrapper date and current time
by Theara Yuom
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js"></script>
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>
<div id="app">
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker v-model="value1" type="date" placeholder="Pick a day">
</el-date-picker>
</div>
<el-button @click="getValue">Get Val</el-button>
</template>
</div>
CSS
@import url("//unpkg.com/[email protected]/lib/theme-default/index.css");
Babel + JSX
var Main = {
data() {
return {
value1: moment().toDate(),
dateValue:'',
};
},
methods:{
getValue(){
alert(this.wrapperDateAndCurrentTime(this.value1));
// When change date, I get the time 00:00:00
// I would like to get date with current time all the time
},
wrapperDateAndCurrentTime (date) {
const dateStr = moment(date).format('YYYY-MM-DD');
const currentTimeStr = moment().format('HH:mm:ss');
return moment(`${dateStr} ${currentTimeStr}`, 'YYYY-MM-DD HH:mm:ss');
}
}
};
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')