npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

natural-date-parser

v1.0.5

Published

Parse natural language dates with country timezone support.

Readme

📦 natural-date-parser

npm version npm downloads license

A lightweight JavaScript library that converts natural language date expressions — like "tomorrow", "next friday", or "2 days ago" — into a structured, timezone-aware date result.

parseDate("next friday at 9am", "US");
// → { success: true, date: '2026-06-26 09:00:00', timezone: 'America/Adak', ... }

📑 Table of Contents


✨ Features

  • 🕒 Parses natural language date expressions
  • 🌍 Returns country & timezone metadata alongside the parsed date
  • 🌎 Accepts both country names and ISO country codes
  • ⚡ Lightweight and fast, no heavy dependencies
  • 📦 Works in both Node.js and the browser
  • 🔌 Simple, single-function
  • 🧩 Supports relative expressions ("in 5 days", "2 days ago", etc.)

📥 Installation

npm install natural-date-parser

Using yarn:

yarn add natural-date-parser

Using pnpm:

pnpm add natural-date-parser

🚀 Quick Start

import parseDate from "natural-date-parser";

// Using a country name
const result1 = parseDate("next friday at 9am", "Germany");

// Using a country code
const result2 = parseDate("next friday at 9am", "DE");

console.log(result1);
console.log(result2);

Output:

{
  success: true,
  input: 'next Friday at 9am',
  country: 'Germany',
  code: 'DE',
  timezone: 'Europe/Berlin',
  date: '2026-07-03 18:00:00'
}

🌍 Country Input

The second argument accepts either:

  • A country name ("Pakistan", "Germany", "United States")
  • An ISO 3166-1 alpha-2 country code ("PK", "DE", "US")

Both formats resolve to the same result — the library handles the lookup internally and returns the matching IANA timezone.


📤 Return Object

parseDate() returns a plain JavaScript object — not a raw Date instance — with the following fields:

| Field | Type | Description | |------------|-----------|--------------------------------------------------------------------| | success | boolean | true if the input was successfully parsed, false otherwise | | input | string | The original string you passed in, echoed back for reference | | country | string | Detected country name used to resolve the timezone | | code | string | ISO 3166-1 alpha-2 country code (e.g. PK) | | timezone | string | IANA timezone identifier (e.g. Asia/Karachi) | | date | string | Parsed date/time, formatted as YYYY-MM-DD HH:mm:ss |


🧠 Example Expressions

parseDate("today", "PK");
parseDate("tomorrow", "Pakistan");

parseDate("yesterday", "DE");
parseDate("next week", "Germany");

parseDate("in 5 days", "US");
parseDate("next friday", "United States");

parseDate("next friday at 9am", "BE");
parseDate("2 days ago", "Belgium");

| Input | Resolves to | |----------------------|---------------------------| | "today" | Current date | | "tomorrow" | +1 day | | "yesterday" | −1 day | | "next week" | +7 days | | "in 5 days" | +5 days | | "next friday" | Upcoming Friday | | "next friday at 9am"| Upcoming Friday, 9:00 AM | | "2 days ago" | −2 days |


🖥️ Compatibility

  • Node.js:
  • Browsers: modern browsers with ES Modules support

🤝 Contributing

Contributions, issues, and feature requests are welcome. Feel free to check the issues page.

git clone https://github.com/Saadjamshaid64/natural-date-parser.git
cd natural-date-parser
npm install

📄 License

Licensed under the Apache License 2.0.