
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@nuxtjs/date-fns
Advanced tools
Modern JavaScript date utility library - date-fns for Nuxt.js
@nuxtjs/date-fns dependency to your projectyarn add --dev @nuxtjs/date-fns # or npm install --save-dev @nuxtjs/date-fns
@nuxtjs/date-fns to the buildModules section of nuxt.config.jsexport default {
buildModules: [
// Simple usage
'@nuxtjs/date-fns',
// With options
['@nuxtjs/date-fns', { /* module options */ }]
]
}
:warning: If you are using Nuxt < v2.9 you have to install the module as a dependency (No --dev or --save-dev flags) and use modules section in nuxt.config.js instead of buildModules.
export default {
buildModules: [
'@nuxtjs/date-fns'
],
dateFns: {
/* module options */
}
}
Add the types to your "types" array in tsconfig.json after the @nuxt/types entry.
:warning: Use @nuxt/vue-app instead of @nuxt/types for nuxt < 2.9.
{
"compilerOptions": {
"types": [
"@nuxt/types",
"@nuxtjs/date-fns"
]
}
}
Why?
For typescript to be aware of the additions to the
nuxt Context, thevue instanceand thevuex store, the types need to be merged via declaration merging by adding@nuxtjs/date-fnsto your types.
localesArray[String][]Locales to be imported.
defaultLocaleStringnullYou can preset default locale.
fallbackLocaleStringnullYou can preset a fallback locale for when a method is called with an unsupported locale.
formatStringnullYou can preset default format.
methodsArraynullMethods to be imported. If not defined all methods are imported.
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({ $dateFns }) {
return {
dateFormatted: $dateFns.format(new Date())
}
}
}
</script>
yarn install or npm installnpm run devCopyright (c) Nuxt Community
FAQs
Modern JavaScript date utility library - date-fns for Nuxt.js
The npm package @nuxtjs/date-fns receives a total of 2,090 weekly downloads. As such, @nuxtjs/date-fns popularity was classified as popular.
We found that @nuxtjs/date-fns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.