Michael Dowling's Blog: Cron Expression Parsing in PHP
Note: This article was originally published at PHPDeveloper on 5 June 2012.
When faced with the task of creating the cron expression parsing part of this system, I searched high and low for an existing implementation in PHP that implemented the full feature set of a modern cron expression. Based on the context of this article, you probably guessed that I didn't find one. I posted the original code I came up with to StackOverflow and eventually open sourced the project.
Not only does the tool let you read from the cron files but it also lets you do other fun things like:
- Determine the next run date for the program
- Calculate the next X number of run dates/times
- Find the last run date of the program
- Check to see if an expression will run on a certain date
The full source for the tool is available for download (and pull requests!) over on github.