2

I use a cdn for momentjs and I try to format my date and time

    @{{ process_photo.created_at.moment().format("Do MMM YYYY") }}

0

1 Answer 1

3

To use momentjs in the template, you'd have to use it indirectly through a component method. For example, you could declare a formatDate method that returns the moment.format() results, and use formatDate in the template:

new Vue({
  el: '#app',
  data() {
    return {
      process_photo: {
        created_at: new Date()
      }
    }
  },
  methods: {
    formatDate(date) {
      return moment(date).format("Do MMM YYYY")
    }
  }
})
<script src="https://unpkg.com/[email protected]">
</script>
<script src="https://unpkg.com/[email protected]/moment.js"></script>

<div id="app">
  <p>@{{ formatDate(process_photo.created_at) }}</p>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.