{
 "kind": "tool",
 "slug": "date-fns",
 "path": "tools/date-fns/",
 "name": "date-fns",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Utilities",
   "tools/utilities/"
  ]
 ],
 "lead": "Format and calculate dates in JavaScript.",
 "chips": [
  {
   "label": "Utilities",
   "path": "tools/utilities/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install date-fns"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/date-fns/date-fns"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software",
   "note": "Free for paid and closed products; keep the MIT notice with the package files.",
   "src": "https://github.com/date-fns/date-fns/blob/main/pkgs/core/LICENSE.md"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Oct 26, 2026",
   "note": "Latest GitHub release May 29, 2026. ",
   "src": "https://github.com/date-fns/date-fns"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "648 projects",
   "status": "info",
   "sub": "#2 of 408 in its category",
   "note": "Dependency in 648 public GitHub projects set up for AI coding agents that we scanned (10.4%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 11, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What date-fns does",
   "parts": [
    {
     "t": "prose",
     "text": "date-fns is a free JavaScript package of small date helpers. Your app shows \"2 days ago\", counts working days to a delivery date or prints a date in German, French or Japanese. It works in the browser and in Node.js, and a companion package handles time zones."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "\"2 days ago\" on comments",
       "text": "A feed or inbox shows how long ago each message came in, in the reader's language.",
       "idea": false
      },
      {
       "title": "Delivery dates without weekends",
       "text": "A shop shows \"arrives Wednesday\" by adding three working days to the order date and skipping Saturday and Sunday.",
       "idea": true
      },
      {
       "title": "One meeting time for every city",
       "text": "An event page shows a 15:00 New York call as 21:00 in Berlin and 05:00 next day in Tokyo.",
       "idea": false
      },
      {
       "title": "Dates in the reader's language",
       "text": "The same date shows as words in English, German or another language; you load only the languages you use.",
       "idea": false
      },
      {
       "title": "Sort and compare dates in a list",
       "text": "Order bookings or posts by date before you show them.",
       "idea": false
      },
      {
       "title": "Dates in file names and reports",
       "text": "Exports get names like report-2026-11-13.csv in a fixed, sortable form.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "date-fns popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "86",
       "of": "/ 100",
       "l": "Gid Score, #26 overall"
      },
      {
       "n": "127M",
       "l": "downloads a week, npm"
      },
      {
       "n": "36.7K",
       "l": "GitHub stars"
      },
      {
       "n": "648",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How date-fns is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "date-fns is a dependency in 648 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (13.3% of the 4,867 JavaScript/TypeScript ones), #2 of 408 in utilities.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,234; those are left out of every share on this page.",
      "The most used alternative in our scan is Lodash (111 projects).",
      "Projects that use it most often also use Lucide React (82.4%), clsx (81.3%), Tailwind Merge (79.6%).",
      "It is more common in projects set up for Kiro (16.4%) than for OpenCode (7.3%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "360 projects, 14.7%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "327 projects, 10.0%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "279 projects, 9.2%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "45 projects, 9.5%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "41 projects, 8.7%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "41 projects, 14.7%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "25 projects, 7.3%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "23 projects, 16.4%",
       "v": "Kiro",
       "path": "agents/kiro/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 82.4% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 81.3% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 79.6% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      },
      {
       "l": "In 76.4% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      },
      {
       "l": "In 69.9% of its projects",
       "v": "Radix UI",
       "path": "tools/radix-ui/"
      },
      {
       "l": "In 92.1% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 89.8% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 61.6% of its projects",
       "v": "Sonner",
       "path": "tools/sonner/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "date-fns in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "200+ functions, Lodash-style",
       "v": "The README pitches date-fns as \"like Lodash for dates\" and says it has 200+ functions. Its own example shows functions such as <code>compareAsc</code> plugging directly into <code>dates.sort()</code>."
      },
      {
       "l": "Leaves Date.prototype alone",
       "v": "The README says date-fns uses the native <code>Date</code> type and \"doesn't extend core objects for safety's sake.\""
      },
      {
       "l": "Returns new instances",
       "v": "The maintainers write that the library is \"Built using pure functions and always returns a new date instance.\""
      },
      {
       "l": "Modular, with locales to match",
       "v": "The README calls the library modular and says it works with webpack, Browserify or Rollup and supports tree-shaking. For i18n, it says there are \"Dozens of locales. Include only what you need.\""
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "CDN scripts are deprecated",
       "v": "v4.4.0 deprecates the CDN scripts shipped in <code>date-fns</code>. They will be removed in the next major release, and in <code>v5.0.0-alpha.0</code> they are already gone. CDN users are told to move to <code>@date-fns/cdn</code>."
      },
      {
       "l": "CDN source maps already removed",
       "v": "v4.4.0 removed the CDN source maps from <code>date-fns</code>. The release notes say <code>@date-fns/cdn</code> still includes them."
      },
      {
       "l": "Package layout still changing",
       "v": "The maintainers say v4.4.0 allowed cutting the zipped package from <code>5.83 MB</code> to <code>3.96 MB</code>, and that v5.0.0-alpha.0 brings it to <code>2.89 MB</code>. They call this \"just the first step\" and say to expect further size reduction in v4 and v5."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Format a date and sort an array of dates"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Js",
       "code": "import { compareAsc, format } from \"date-fns\";\n\nformat(new Date(2014, 1, 11), \"yyyy-MM-dd\");\n//=> '2014-02-11'\n\nconst dates = [\n  new Date(1995, 6, 2),\n  new Date(1987, 1, 11),\n  new Date(1989, 6, 10),\n];\ndates.sort(compareAsc);\n//=> [\n//   Wed Feb 11 1987 00:00:00,\n//   Mon Jul 10 1989 00:00:00,\n//   Sun Jul 02 1995 00:00:00\n// ]"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about date-fns",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/kossnocorp",
        "Open Collective: https://opencollective.com/date-fns",
        "10 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "date-fns vs Day.js",
         "note": "used together in 21 projects",
         "path": "tools/compare/date-fns-vs-dayjs/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "lucide-react: Icon components",
        "clsx: className builder",
        "tailwind-merge: Tailwind class merging",
        "class-variance-authority: Component variants",
        "@radix-ui: UI primitives",
        "react: UI library"
       ]
      },
      {
       "title": "More in Utilities",
       "path": "tools/utilities/",
       "items": [
        {
         "text": "clsx",
         "path": "tools/clsx/"
        },
        {
         "text": "PyYAML",
         "path": "tools/pyyaml/"
        },
        {
         "text": "uuid",
         "path": "tools/uuid/"
        },
        {
         "text": "yaml",
         "path": "tools/yaml/"
        },
        {
         "text": "js-yaml",
         "path": "tools/js-yaml/"
        },
        {
         "text": "glob",
         "path": "tools/glob/"
        },
        {
         "text": "tqdm",
         "path": "tools/tqdm/"
        },
        {
         "text": "Nanoid (JavaScript)",
         "path": "tools/nanoid-npm/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "date-fns",
       "me": true,
       "facts": [
        "MIT",
        "Gid 86",
        "127M/wk"
       ]
      },
      {
       "name": "Day.js",
       "why": "Pick Day.js when you want a very small library with a chained, Moment.js-like style.",
       "path": "tools/dayjs/",
       "facts": [
        "MIT",
        "Gid 82",
        "117M/wk"
       ]
      },
      {
       "name": "Luxon",
       "why": "Pick Luxon when you want one DateTime object with time zones and formatting built in, rather than separate helpers.",
       "path": "tools/luxon/",
       "facts": []
      },
      {
       "name": "temporal-polyfill",
       "why": "Pick the Temporal polyfill to write code against JavaScript's new standard date API today.",
       "path": "tools/temporal-polyfill/",
       "facts": []
      },
      {
       "name": "Lodash",
       "why": "Modular utility library with methods for common programming tasks and data manipulation.",
       "path": "tools/lodash/",
       "facts": [
        "MIT",
        "Gid 84",
        "212M/wk"
       ]
      },
      {
       "name": "Moment.js",
       "why": "Parse, validate, manipulate and format dates and times in JavaScript.",
       "path": "tools/moment/",
       "facts": [
        "MIT",
        "Gid 75",
        "52.2M/wk"
       ]
      }
     ],
     "more": "Compare date-fns with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use date-fns 4.4.0 (and @date-fns/tz for time zones) to format and calculate these dates; use the tokens yyyy and dd, not YYYY and DD, and import only the locales the app needs."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add date-fns to your project.",
       "code": "npm install date-fns --save",
       "src": "https://github.com/date-fns/date-fns/blob/main/pkgs/core/docs/gettingStarted.md"
      },
      {
       "text": "Import only the helpers you use and call them on normal JavaScript dates.",
       "code": "import { formatDistance, subDays } from \"date-fns\";\n\nformatDistance(subDays(new Date(), 3), new Date(), { addSuffix: true });\n//=> \"3 days ago\"\n",
       "src": "https://github.com/date-fns/date-fns/blob/main/pkgs/core/docs/gettingStarted.md"
      },
      {
       "text": "For time zones, add the companion package and use TZDate.",
       "code": "npm install @date-fns/tz --save",
       "src": "https://github.com/date-fns/date-fns/blob/main/pkgs/tz/README.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## date-fns\n- Install with `npm install date-fns --save`. Import functions by name, as the README does: `import { compareAsc, format } from \"date-fns\"`.\n- Use the value a date-fns call returns. The README says the library \"always returns a new date instance\".\n- To sort dates, pass the comparator directly, e.g. `dates.sort(compareAsc)`, as in the README example.\n- For year-month-day output, follow the README's token casing `\"yyyy-MM-dd\"`. Do not copy `'yyyy-mm-dd'` from blog posts without checking the token in the docs.\n- For date-only values that must not shift for users in other time zones, consider the Atomic Object approach: build dates from a string with date-fns `parse` instead of `new Date()`.\n- Include only the locales the app needs. The README says \"Dozens of locales. Include only what you need.\"\n- For CDN usage, use `@date-fns/cdn`. The `date-fns` CDN scripts are deprecated and will be removed in the next major release.\n"
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "format(date, 'YYYY-MM-DD')",
       "fix": "format(date, 'yyyy-MM-dd')",
       "why": "YYYY is the week-numbering year and DD the day of the year; in our run date-fns 4.4.0 threw a RangeError for this."
      },
      {
       "dont": "Adding date-fns-tz for time zones in a date-fns 4 project",
       "fix": "npm install @date-fns/tz and use TZDate or the in option",
       "why": "date-fns 4 has its own time zone package; the docs point to date-fns-tz only for older versions."
      },
      {
       "dont": "<script src=\"https://cdn.jsdelivr.net/npm/date-fns/cdn.min.js\">",
       "fix": "<script src=\"https://cdn.jsdelivr.net/npm/@date-fns/cdn@4.4.0/cdn.min.js\">",
       "why": "The CDN files inside date-fns are deprecated, log a notice and are removed in version 5."
      },
      {
       "dont": "Doing date math with new Date() on a server and expecting the user's local day",
       "fix": "Create a TZDate in the user's time zone, or pass in tz('Zone/Name') to the helper",
       "why": "Plain dates use the server's time zone, so summer-time shifts and day borders come out wrong for users elsewhere."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Does date-fns handle time zones?",
       "a": "Yes, since version 4, through the separate @date-fns/tz package and its TZDate class.",
       "evidence": {
        "url": "https://github.com/date-fns/date-fns/blob/main/pkgs/core/docs/timeZones.md",
        "quote": "Starting from v4, date-fns has first-class support for time zones."
       }
      },
      {
       "q": "Why does format(date, 'YYYY-MM-DD') throw an error?",
       "a": "YYYY is the week-numbering year and DD the day of the year; use yyyy-MM-dd. date-fns refuses those tokens unless you turn them on.",
       "evidence": {
        "url": "https://github.com/date-fns/date-fns/blob/main/pkgs/core/docs/unicodeTokens.md",
        "quote": "To help with the issue, format and parse functions won't accept these tokens without useAdditionalDayOfYearTokens option for D and DD and useAdditionalWeekYearTokens options for YY and YYYY"
       }
      },
      {
       "q": "Does it change my Date objects?",
       "a": "No. Every helper returns a new date and leaves the one you passed alone.",
       "evidence": {
        "url": "https://github.com/date-fns/date-fns/blob/main/README.md",
        "quote": "Immutable & Pure: Built using pure functions and always returns a new date instance."
       }
      },
      {
       "q": "Can I still use require() instead of import?",
       "a": "Yes. Version 4 is ESM-first but still ships CommonJS files.",
       "evidence": {
        "url": "https://blog.date-fns.org/v40-with-time-zone-support/",
        "quote": "Some of you'll be happy to learn that date-fns v4.0 is still a dual ESM/CommonJS package."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm date-fns"
  ],
  [
   "Category",
   "Utilities"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v4.4.0, May 29, 2026"
  ],
  [
   "On GitHub since",
   "October 2014"
  ],
  [
   "Gid Score",
   "86.3"
  ],
  [
   "Rank in category",
   "#2 of 408"
  ],
  [
   "GitHub",
   "date-fns/date-fns"
  ],
  [
   "Last change",
   "Oct 26, 2026"
  ]
 ],
 "good": [
  "Time zones need the separate @date-fns/tz package; date-fns alone uses the time zone of the computer it runs on.",
  "Format letters follow the Unicode standard, not Moment.js; YYYY and DD mean other things than yyyy and dd.",
  "The ready-to-load script files inside the date-fns package are deprecated; pages that load it with a script tag should switch to @date-fns/cdn."
 ],
 "checked_line": "Read by AgentGid from 10 official pages, card checked Nov 11, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/date-fns.png"
}