pretityCron is a simple JavaScript deuglifier for cron schedules: it prints out a human-readable interpretation of when the schedule will run.


Loading ...

Examples using seconds

Loading ...

Installation - browser

Include prettycron.js after adding moment.js and later.js.
  <script src="moment.min.js" type="text/javascript"></script>
  <script src="later.min.js" type="text/javascript"></script>
  <script src="prettycron.js" type="text/javascript"></script>

Installation - Node

Simply use npm and require:
  $ npm install prettycron
  var prettyCron = require('prettycron');


prettyCron exposes two methods, both of which take a cron specification as the only argument.


Returns a human-readable sentence describing all the times this cron will run.
  prettyCron.toString("37 10 * * *");
  // returns "10:37 every day"

prettyCron.toString(cron, true)

Returns a human-readable sentence describing all the times this cron (with six parameters to specify seconds) will run.
  prettyCron.toString("*/2 * * * * *", true);
  // returns "Every other second"


Returns a string representing the next time this cron will run, formatted with moment's calendar() method.
  prettyCron.getNext("0 * * * *");
  // if current time is 4:45pm, then returns "Today at 5:00 PM"

Used by


prettyCron was originally written by dunse and posted to gist. This version is by Hourann Bosci with contributions from Johan Andersson, Phil Jepsen, Andre Buchanan, and Anton Petrov.

It's licensed under LGPLv3.