Created
December 1, 2019 03:51
-
-
Save bellx2/fd35db4801284453304155d7e7653aa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.jsdelivr.net/npm/vue"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.js"></script> | |
<div id="app"> | |
<input v-model="mytime"> | |
<p> | |
<p>FromNow : {{ time_diff() }} | |
<p>Diff(sec) : {{ time_diff_sec() }} | |
</div> | |
<script> | |
var app = new Vue({ | |
el: '#app', | |
data: { | |
mytime: moment().format("YYYY/MM/DD HH:mm:ss"), | |
}, | |
methods: { | |
time_diff: function(){ | |
moment.locale('ja') | |
return moment(this.mytime).fromNow() | |
}, | |
time_diff_sec: function(){ | |
return moment(this.mytime).diff(moment(),'seconds') | |
} | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment