
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
@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.
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(ctx) {
return {
// $dateFns is available in context
dateFormatted: ctx.app.$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
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 Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.