Dayjs – Processing time
The document address
Dayjs. Fenxianglu. Cn/category/di…
The installation package
npm install dayjs --save
Copy the code
use
<template>
<div>
</div>
</template>
<script>
// Must import: Import package use
const dayjs = require('dayjs')
// Other imports: imports as needed
var weekYear = require('dayjs/plugin/weekYear')
var weekOfYear = require('dayjs/plugin/weekOfYear')
var isoWeeksInYear = require('dayjs/plugin/isoWeeksInYear')
var isLeapYear = require('dayjs/plugin/isLeapYear')
dayjs.extend(weekOfYear)
dayjs.extend(weekYear)
dayjs.extend(isoWeeksInYear)
dayjs.extend(isLeapYear)
export default {
data () {
return{}},methods: {
},
created () {
// console.log(early -----------------------')
// console.log(dayjs().startOf('month').format('YYYY-MM-DD 00:00'))
// console.log(end of month -----------------------')
// console.log(dayjs().endOf('month').format('YYYY-MM-DD 23:59'))
// console.log(current time -----------------------')
// console.log(dayjs().format('YYYY-MM-DD 23:59'))
// console.log(' early last month -----------------------')
// console.log(dayjs().startOf('month').subtract(1, 'month').format('YYYY-MM-DD 00:00'))
// console.log(' end of last month -----------------------')
// console.log(dayjs().endOf('month').subtract(1, 'month').format('YYYY-MM-DD 23:59'))
// console.log(' Number of days to get the month -----------------------')
// console.log(dayjs().daysInMonth())
// console.log(' get timestamp -----------------------')
// console.log(dayjs('2019-01-25').valueof ()
// console.log(dayjs('2019-01-25').unix()) // second
// console.log(' get the current week -----------------------')
// console.log(' day '+ dayjs().week() +' week ')
// console.log(' total year '+ dayjs().isoweeksinYear () +' week ')
// console.log('15 days later -----------------------')
// console.log(dayjs().add(15, 'day').format('YYYY-MM-DD'))
// console.log('15 days ago -----------------------')
// console.log(dayjs().add(-15, 'day').format('YYYY-MM-DD'))
// console.log(' leap year or not -----------------------')
// console.log(dayjs().isLeapYear())}},</script>
<style lang="scss" scoped>
</style>
Copy the code