https://github.com/boldgrid/tdcron
A clone of chland/tdcron
https://github.com/boldgrid/tdcron
Last synced: 10 months ago
JSON representation
A clone of chland/tdcron
- Host: GitHub
- URL: https://github.com/boldgrid/tdcron
- Owner: BoldGrid
- License: mit
- Created: 2022-11-01T15:37:44.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T17:50:50.000Z (about 2 years ago)
- Last Synced: 2025-05-25T15:18:20.362Z (about 1 year ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
> **WARNING**: This class was written back in 2010 ! Its pretty much untested with all PHP versions > 5.6.0 and might act funny. I mostly pushed it to GitHub for easier access and in case if somebody is looking for a simple cron-parser.
# tdCron
tdCron is a ***very*** simple class to parse cron-expressions and calculate schedules.
For something more sophisticated (and WAY more modern) you can take a look at the [cron-expression](https://github.com/dragonmantank/cron-expression) package by Michael Dowling and Chris Tankersley.
## Getting Started
### Installation
Just include `class.tdcron.php` and `class.tdcron.entry.php` in your project and you're done.
## Documentation
As i mentioned before - this class is really, really simple :-)
Please just look at the code in `test.php` and `class.tdcron.php` - its reasonably well documented and should be pretty easy to understand.
It basically comes down to calling `tdCron::getNextOccurrence()` or `tdCron::getLastOccurrence()` with your cron-expression as the first parameter and an optional reference-time as the second parameter.
Lets say you've got a cron-expression like `5 0 * 8 2` (so something at 00:05 on every tuesday in august). You could use something like
echo 'next: '.date('d.m.Y, H:i:s', tdCron::getNextOccurrence('5 0 * 8 2');
to see when it should run the next time.
## Running the tests
There aren't any "real" tests included with the class (so you won't find any PHPUnit-stuff here). You can find a bunch of edge-cases in the test.php / test.data.php files that were used to test the class during development.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details