Socket
Book a DemoInstallSign in
Socket

@nuxtjs/date-fns

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/date-fns

Modern JavaScript date utility library - date-fns for Nuxt.js

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2.3K
-11.01%
Maintainers
1
Weekly downloads
 
Created
Source

@nuxtjs/date-fns

npm version npm downloads Circle CI Codecov License

Modern JavaScript date utility library - date-fns for Nuxt.js

📖 Release Notes

Setup

  • Add @nuxtjs/date-fns dependency to your project
yarn add @nuxtjs/date-fns # or npm install @nuxtjs/date-fns
  • Add @nuxtjs/date-fns to the modules section of nuxt.config.js
{
  modules: [
    // Simple usage
    '@nuxtjs/date-fns',

    // With options
    ['@nuxtjs/date-fns', { /* module options */ }]
  ]
}

Using top level options

{
  modules: [
    '@nuxtjs/date-fns'
  ],
  dateFns: {
    /* module options */
  }
}

Options

locales

  • Default: []

Locales to be imported.

defaultLocale

  • Default: null

You can preset default locale.

format

  • Default: null

You can preset default format.

Usage

This module inject $dateFns to your project:

<template>
  <div>
    // Using default format and locale
    {{ $dateFns.format(new Date()) }}

    // Using custom format
    {{ $dateFns.format(new Date(), 'yyyy-MM-dd') }}

    // Using custom format and locale
    {{ $dateFns.format(new Date(), 'yyyy-MM-dd', { locale: 'ru' }) }}

    // Using asyncData
    {{ dateFormatted }}
  </div>
</template>

<script>
export default {
  asyncData(ctx) {
    return {
      // $dateFns is available in context
      dateFormatted: ctx.app.$dateFns.format(new Date())
    }
  }
}
</script>

License

MIT License

Copyright (c) Nuxt Community

FAQs

Package last updated on 05 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts