I am trying to use Moment Timezone in my code. I tried to include it in vendor/laravel/spark/resources/assets/js/spark-bootstrap.js file with the code
window.moment.tz = require('moment-timezone/builds/moment-timezone-with-data.min');
after
window.moment = require('moment');
I am trying to use it in the following code:
var base = require('auth/register-stripe');
Vue.component('spark-register-stripe', {
mixins: [base],
...
created() {
this.guessTimezone();
},
methods: {
/**
* Attempt to guess the user's timezone.
*/
guessTimezone() {
this.registerForm.user_tz = moment.tz.guess();
}
}
});
And I am getting the error:
[Vue warn]: Error in created hook: "TypeError: moment.tz.guess is not a function"
What causes this error and how to fix it?