{"id":13828488,"url":"https://github.com/adhocore/php-cron-expr","last_synced_at":"2025-04-13T06:37:26.360Z","repository":{"id":43921664,"uuid":"94228363","full_name":"adhocore/php-cron-expr","owner":"adhocore","description":"Ultra lightweight, Dependency free and Super Fast Cron Expression parser for PHP","archived":false,"fork":false,"pushed_at":"2024-05-24T16:29:02.000Z","size":105,"stargazers_count":52,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T10:41:36.148Z","etag":null,"topics":["adhocore","cron","cron-expr","cron-expression","cron-parser","cron-relay","crontab","crontab-parser","php-cron","php-crontab","scheduler"],"latest_commit_sha":null,"homepage":"https://github.com/adhocore/php-cron-expr","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adhocore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"adhocore","custom":["https://paypal.me/ji10"]}},"created_at":"2017-06-13T15:30:07.000Z","updated_at":"2025-01-19T19:40:52.000Z","dependencies_parsed_at":"2024-06-18T19:48:45.593Z","dependency_job_id":"34a77b20-5ec9-4853-9d3c-15a1e08e1357","html_url":"https://github.com/adhocore/php-cron-expr","commit_stats":{"total_commits":100,"total_committers":4,"mean_commits":25.0,"dds":"0.050000000000000044","last_synced_commit":"b308d86d4a6fb0b647961e66a75d88ac48a42f9d"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cron-expr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cron-expr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cron-expr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cron-expr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adhocore","download_url":"https://codeload.github.com/adhocore/php-cron-expr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675350,"owners_count":21143763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adhocore","cron","cron-expr","cron-expression","cron-parser","cron-relay","crontab","crontab-parser","php-cron","php-crontab","scheduler"],"created_at":"2024-08-04T09:02:49.087Z","updated_at":"2025-04-13T06:37:26.330Z","avatar_url":"https://github.com/adhocore.png","language":"PHP","funding_links":["https://github.com/sponsors/adhocore","https://paypal.me/ji10","https://www.paypal.me/ji10/15usd","https://www.paypal.me/ji10/25usd","https://www.paypal.me/ji10/50usd"],"categories":["PHP"],"sub_categories":[],"readme":"## adhocore/cron-expr\n\n[![Latest Version](https://img.shields.io/github/release/adhocore/php-cron-expr.svg?style=flat-square)](https://github.com/adhocore/php-cron-expr/releases)\n[![Travis Build](https://img.shields.io/travis/adhocore/php-cron-expr/master.svg?style=flat-square)](https://travis-ci.org/adhocore/php-cron-expr?branch=master)\n[![Scrutinizer CI](https://img.shields.io/scrutinizer/g/adhocore/php-cron-expr.svg?style=flat-square)](https://scrutinizer-ci.com/g/adhocore/php-cron-expr/?branch=master)\n[![Codecov branch](https://img.shields.io/codecov/c/github/adhocore/php-cron-expr/master.svg?style=flat-square)](https://codecov.io/gh/adhocore/php-cron-expr)\n[![StyleCI](https://styleci.io/repos/94228363/shield)](https://styleci.io/repos/94228363)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Lightweight+and+fast+cron+expression+parser+for+PHP\u0026url=https://github.com/adhocore/php-cron-expr\u0026hashtags=php,cron,cronparser,parser,cronexpr)\n[![Support](https://img.shields.io/static/v1?label=Support\u0026message=%E2%9D%A4\u0026logo=GitHub)](https://github.com/sponsors/adhocore)\n\u003c!-- [![Donate 15](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+15)](https://www.paypal.me/ji10/15usd)\n[![Donate 25](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+25)](https://www.paypal.me/ji10/25usd)\n[![Donate 50](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+50)](https://www.paypal.me/ji10/50usd) --\u003e\n\n\n- Lightweight Cron expression parser library for PHP.\n- Zero dependency.\n- Very **fast** because it bails early in case a segment doesnt match.\n- Real [benchmark](https://github.com/adhocore/php-cron-bench) shows it is about 7.54x to 12.92x faster than `dragonmantank/cron-expression`\n\n## Installation\n\n```bash\ncomposer require adhocore/cron-expr\n\n# PHP5.6 or lower\ncomposer require adhocore/cron-expr:0.1.0\n```\n\n## Usage\n\n**Basic**\n\n```php\nuse Ahc\\Cron\\Expression;\nuse Ahc\\Cron\\Normalizer;\n\nExpression::isDue('@always');\nExpression::isDue(Normalizer::HOURLY, '2015-01-01 00:00:00');\nExpression::isDue('*/20 * * * *', new DateTime);\nExpression::isDue('5-34/4 * * * *', time());\n\n// Dont like static calls? Below is possible too!\n$expr = new Expression;\n$expr-\u003eisCronDue('*/1 * * * *', time());\n```\n\n**Bulk checks**\n\nWhen checking for several jobs at once, if more than one of the jobs share equivalent expression\nthen the evaluation is done only once per go thus greatly improving performnce.\n\n```php\nuse Ahc\\Cron\\Expression;\n\n$jobs = [\n    'job1' =\u003e '*/2 */2 * * *',\n    'job1' =\u003e '* 20,21,22 * * *',\n    'job3' =\u003e '7-9 * */9 * *',\n    'job4' =\u003e '*/5 * * * *',\n    'job5' =\u003e '@5minutes',     // equivalent to job4 (so it is due if job4 is due)\n    'job6' =\u003e '7-9 * */9 * *', // exact same as job3 (so it is due if job3 is due)\n];\n\n// The second param $time can be used same as above: null/time()/date string/DateTime\n$dues = Expression::getDues($jobs, '2015-08-10 21:50:00');\n// ['job1', 'job4', 'job5']\n\n// Dont like static calls? Below is possible too!\n$expr = new Expression;\n$dues = $expr-\u003efilter($jobs, time());\n```\n\n### Cron Expression\n\nCron expression normally consists of 5 segments viz:\n```\n\u003cminute\u003e \u003chour\u003e \u003cday\u003e \u003cmonth\u003e \u003cweekday\u003e\n```\nand sometimes there can be 6th segment for `\u003cyear\u003e` at the end.\n\n### Real Abbreviations\n\nYou can use real abbreviations for month and week days. eg: `JAN`, `dec`, `fri`, `SUN`\n\n### Tags\n\nFollowing tags are available and they are converted to real cron expressions before parsing:\n\n- *@yearly* or *@annually* - every year\n- *@monthly* - every month\n- *@daily* - every day\n- *@weekly* - every week\n- *@hourly* - every hour\n- *@5minutes* - every 5 minutes\n- *@10minutes* - every 10 minutes\n- *@15minutes* - every 15 minutes\n- *@30minutes* - every 30 minutes\n- *@always* - every minute\n\n\u003e You can refer them with constants from `Ahc\\Cron\\Normalizer` like `Ahc\\Cron\\Normalizer::WEEKLY`\n\n### Modifiers\n\nFollowing modifiers supported\n\n- *Day of Month / 3rd segment:*\n    - `L` stands for last day of month (eg: `L` could mean 29th for February in leap year)\n    - `W` stands for closest week day (eg: `10W` is closest week days (MON-FRI) to 10th date)\n- *Day of Week / 5th segment:*\n    - `L` stands for last weekday of month (eg: `2L` is last monday)\n    - `#` stands for nth day of week in the month (eg: `1#2` is second sunday)\n\n## LICENSE\n\n\u003e \u0026copy; [MIT](./LICENSE) | 2017-2019, Jitendra Adhikari\n\n## Credits\n\nThis project is release managed by [please](https://github.com/adhocore/please).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-cron-expr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadhocore%2Fphp-cron-expr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-cron-expr/lists"}