Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <span>{{ localDate }}</span>
- </template>
- <script>
- import moment from 'moment-timezone';
- export default {
- props: ['date', 'input_format', 'output_format'],
- data(){
- return {
- format: {
- input: 'YYYY-MM-DD HH:mm:ss',
- output: 'MMM DD, YYYY h:mm:ss A'
- }
- };
- },
- mounted(){
- if(this.input_format){
- this.format.input = this.input_format;
- }
- if(this.output_format){
- this.format.output = this.output_format;
- }
- },
- computed: {
- localDate(){
- return moment.tz(this.date, this.format.input, 'UTC').tz(moment.tz.guess()).format(this.format.output);
- }
- }
- }
- </script>
- <style scoped="">
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement