PHP code example of garethellis / crontab-schedule-generator

1. Go to this page and download the library: Download garethellis/crontab-schedule-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

garethellis / crontab-schedule-generator example snippets



use function Garethellis\CrontabScheduleGenerator\every`

echo every("5")->minutes();
//outputs "*/5 * * * *" (i.e. run every 5 minutes)

echo every("2")->hours();
//outputs "0 */2 * * *" (i.e. run every 2 hours on the hour)

echo every("3")->hours()->at("half past");
//outputs "30 */3 * * *" (i.e. run every 3 hours at half past the hour)

echo every("2")->hours()->from("8")->until("14");
//outputs "0 8,10,12,14 * * *" (i.e. run on the hour at 8am, 10am, 12pm and 2pm)

 php
use function Garethellis\CrontabScheduleGenerator\monthly;

echo monthly();
//outputs "0 0 1 * *"   
   
echo monthly()->on("4th");
//outputs "0 0 4 * *" (i.e. run every month on the 4th at midnight)   
   
echo monthly()->on("12th")->at("10:15");
//outputs "15 10 12 * *" (i.e. run every month on the 12th at 10:15am)