Vue 1.x Moment.js Wrapper

1.0.0 · abandoned · verified Sun Apr 19

This package, `vue-momentjs` v1.0.0, serves as a lightweight wrapper for the Moment.js library, designed specifically for applications built with Vue.js version 1.x. It simplifies integrating Moment.js functionalities into Vue components by exposing a `$moment()` instance. Released approximately six years ago and last updated around that time, the package is now considered abandoned. Its core dependency, Moment.js, has been in maintenance mode since September 2020 and is not recommended for new projects due to concerns regarding bundle size, object mutability, and modern JavaScript ecosystem compatibility. Furthermore, Vue 1.x has reached its end-of-life, making `vue-momentjs` incompatible with modern Vue 2.x or Vue 3.x applications. Users requiring date manipulation in current Vue projects should consider actively maintained alternatives like Day.js, Luxon, or `date-fns` with dedicated Vue 2/3 integrations.

Common errors

Warnings

Install

Imports

Quickstart

Initializes `vue-momentjs` with Moment.js and demonstrates basic date formatting within a Vue 1.x component.

import Vue from 'vue';
import moment from 'moment';
import VueMomentJS from 'vue-momentjs';

// Install the plugin, passing the Moment.js library instance
Vue.use(VueMomentJS, moment);

// Create a basic Vue component
const app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue with Moment.js!'
  },
  mounted() {
    // Use this.$moment() to access Moment.js functionalities
    console.log('Current time:', this.$moment().format('MMMM Do YYYY, h:mm:ss a'));
    this.message = `Current time: ${this.$moment().format('MMMM Do YYYY, h:mm:ss a')}`;
  },
  template: `
    <div>
      <h1>{{ message }}</h1>
      <p>Formatted date from instance: {{ this.$moment('2023-01-15').format('dddd, MMMM Do YYYY') }}</p>
    </div>
  `
});

// Ensure you have a div with id='app' in your HTML:
// <div id="app"></div>

view raw JSON →