You get this error because moment is now a variable and not a method anymore! Instead it's better to import moment js on the component itself. This way it will only be loaded where you use it!
For example
// show.vue
<template>
<div>
{{ moment.format('Y-m-d') }}
</div>
</template>
<script>
import moment from 'moment';
export default {
data () {
return {
variable: 'data'
}
}
}
</script>
@BOBBYBOUWMANN - Thanks all, for replies! Did everything as you told me but still getting the same error :(
[Vue warn]: Property or method "moment" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <User> at resources/js/components/users/show.vue
<VContent>
<VApp>
<Root>
@MaverickChan It wasn’t intentional. I skimmed the thread and replied from my phone this morning on the way to work. Sorry if you think I was copying you.
Hi, I have a follow-up question about this. I'm using standard blade views in my project and retrieve UTC date/time stamps from the database by e.g. {{ $project->created_at }}. I would like to show them in the local user's time zone. I assume that just replacing {{ formattedDate }} by {{ $project->created_at }} is not going to work. Could you please give me a pointer as to how to go about this?
@ingo1977 Moment.js is a JavaScript framework. If you’re using Blade, you’ll need to use Carbon to format your dates. If you want to show a date in a user’s timezone, then you’ll need to get the user’s timezone preference from somewhere and set that on your date instance: