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

get-cron

v1.1.0

Published

Convert dates into cron expressions. Skip the syntax, just pass a date.

Downloads

298

Readme

get-cron

Convert JavaScript dates into cron expressions without writing cron syntax.

get-cron is a lightweight utility that converts JavaScript ISO dates into valid cron expressions.

Instead of memorizing cron syntax like:

30 14 * * 1-5

you simply write:

import getCron from "get-cron";

const cron = getCron({
  at: "2026-06-30T14:30",
  every: "weekday"
});

console.log(cron);

// 30 14 * * 1-5

Features

  • Convert JavaScript dates into cron expressions.
  • Simple and intuitive API.
  • Built in scheduling patterns.
  • Lightweight.
  • Zero dependencies.
  • Modern ES Modules.
  • Perfect companion for node-cron and the foundation powering crondis.

Installation

npm install get-cron

Requires Node.js 20 or later.


Quick Start

import getCron from "get-cron";

const cron = getCron({
  at: "2026-08-12T09:00",
  every: "yearly"
});

console.log(cron);

// 0 9 12 8 *

API

getCron()

getCron({
  at,
  every
});

| Property | Type | Required | Description | |----------|------|----------|-------------| | at | String | Yes | A valid JavaScript ISO date. | | every | String | Yes | The repeat schedule. |

Returns a valid cron expression.


Supported Repeat Options

| Option | Description | |---------|-------------| | once | Run only once. | | daily | Every day. | | weekly | Every week on the same weekday. | | monthly | Same day every month. | | yearly | Same day every year. | | weekday | Monday through Friday. | | weekends | Saturday and Sunday. | | christmas | Every Christmas Day. | | christmas-eve | Every Christmas Eve. | | new year | Every New Year's Day. | | new years-eve | Every New Year's Eve. | | valentines | Every Valentine's Day. |


Named/Additional Exports

get-cron currently exports:

import getCron, {
  parseDate
} from "get-cron";

parseDate()

const date = parseDate("2026-06-30T20:14");

console.log(date);

Returns

{
  minutes: 14,
  hour: 20,
  date: 30,
  month: 6,
  weekday: "Tuesday"
}

Errors

get-cron throws descriptive errors when:

  • at is not a valid JavaScript ISO date.
  • every contains an unsupported repeat option.

Example:

TypeError: The "at" property must be a valid ISO date.
Error: Unsupported repeat option: "everyday"

Common Errors

Example-1:

getCron({
  at: "2026",
  every: "daily"
});

Error: Invalid ISO date

Example-2:

getCron({
  at: "2026-07-14T10:00",
  every: "everyday"
});

Error: Unsupported repeat option


Why get-cron?

Cron expressions are powerful, but they're difficult to remember and easy to get wrong.

get-cron lets you think in JavaScript dates while it handles the cron syntax for you.


Roadmap

Upcoming releases will include:

  • Better validation.
  • Better error output.
  • Improved API.
  • More repeat options.
  • TypeScript support.
  • Timezone helpers.
  • Natural language scheduling.
  • Support for briefer dates, e.g time (12:30 or 12:30:00) only for weekly, daily, once, weekends, options, other than 2026-07-14T12:30.
  • Timestamp date support (e.g 1829692800)

Contributing

Contributions are welcome.

Feel free to open an Issue or submit a Pull Request.


Changelog

See the full project history in:

changelog.md

License

MIT


Author

Victor Usen

GitHub

https://github.com/victusen


Related Project

If you're looking for a complete task scheduler built on top of get-cron, check out:

  • Crondis — https://github.com/victusen/crondis

If get-cron saved you time, please consider giving the project a ⭐ on GitHub.

Every star helps more developers discover the project.