Even a weak butterfly can fly higher as long as it tries to fly

preface

I’ve had a good time, though I’ve had some down times. Tomorrow is another day

1 introduction

Analytical parameters

The default

moment()
Copy the code

The time stamp

moment(1318781876406)
Copy the code

(date) (month) (year)

moment('2021-02-27 20:30:30')
Copy the code

Week in week

moment('2021-W01-7')
Copy the code

Commonly used method

format

// Format moment(). Format ('YYYY-MM-DD hh: MM :ss')Copy the code

valueOf

// Time stamp moment().valueof ()Copy the code

add

// 7 days later moment().add(7, 'd')Copy the code

subtract

// Moment ().subtract(2, 'h')Copy the code

isBetween

Moment (now).isbetween (startDate, endDate)Copy the code

2 use

The installation

npm install moment -S
Copy the code

.vue

<template>
  <div class="home">
    <p>{{ moment }}</p>
    <p>{{ moment.format() }}</p>
    <p>{{ moment.format('YYYY-MM-DD hh:mm:ss') }}</p>
  </div>
</template>

<script>
import moment from 'moment'

export default {
  name: 'Home',
  data: {
    return {
      moment
    }
  }
}
</script>
Copy the code

3. Pay attention to

1. Use it directly after installation

The end of the

The little stars in the sky have stopped blinking, you also want to go to sleep soon

Good night ^_^

Refer to the link

  • Momentjs document

Review past

  • Learn a Vue plugin (1) every day — Better scroll
  • Learn a VUE plugin (2) every day — vue-awesome-swiper
  • Learn a vUE plugin every day (3) — esLint + prettier + stylelint
  • Learn a VUE plugin (4) every day — the V-Viewer
  • Learn a vUE plugin (5) every day — PostCSs-pxtorem