appsketch/human-cron

A laravel package for converting a cron string to a 'time ago' or a 'time from now' string.

This package's canonical repository appears to be gone and the package has been frozen as a result.

v1.0.0 2015-07-26 19:22 UTC

This package is not auto-updated.

Last update: 2024-02-03 14:53:15 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

First, pull in the package through Composer.

composer require appsketch/human-cron

And then, if using Laravel 5.1, include the service provider within app/config/app.php.

'providers' => [
    Appsketch\HumanCron\Providers\HumanCronServiceProvider::class,
]

if using Laravel 5. include this service provider.

'providers' => [
    "Appsketch\HumanCron\Providers\HumanCronServiceProvider",
]

The alias will automatically set.

Usage

Within, for example the routes.php add this.

Route::get('/cron', function()
{
    // Cron
    $cron = '0,30 * * * * *';
    
    // Will echo e.g. '1 minute from now'
    echo HumanCron::cron($cron)->next();
    
    // Will echo e.g. '2 minutes ago'
    echo HumanCron::cron($cron)->previous();
    
    // Will print an array with both; next and previous.
    print_r(HumanCron::cron($cron)->both());
});