brofian/cron-translator

A simple and lightweight cron expression to human readable translator

0.2.4 2023-03-14 10:20 UTC

This package is auto-updated.

Last update: 2024-11-14 14:36:00 UTC


README

A simple tool to create a readable text for humans from a cronjob expression.

Supported languages:

  • de
  • en (comming soon)

Hint: I created this package, because i was not completely satisfied with the (at this time) most popular solution lorisleiva/cron-translator and wanted to create a much more simple way. If you are searching for a professional solution, i would recommend the other package

Installation

composer require brofian/cron-translator

Usage

use Brofian\CronTranslator\CronTranslator;

// 'Jede Minute'
echo CronTranslator::expressionToString('* * * * *');

// 'Jede Minute der 1.Stunde an jedem 2.Tag, im März am einem Donnerstag'
echo CronTranslator::expressionToString('* 1 2 3 4');

// 'Die 17. und 30.Minute der 2.Stunde von Montag bis Freitag'
echo CronTranslator::expressionToString('17,30 2 * * 1-5');

// 'Jede 15.Minute von 10 Uhr bis 12 Uhr von Montag bis Freitag'
echo CronTranslator::expressionToString('*/15 10-12 * * 1-5');

A second parameter can be passed to select the language: (currently, only german is available)

echo CronTranslator::expressionToString('* * * * *', 'de');