PHP code example of matthewdavis / duration

1. Go to this page and download the library: Download matthewdavis/duration 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/ */

    

matthewdavis / duration example snippets


use MatthewDavis\Duration\Duration;

$seconds = Duration::days(3)->inSeconds(); // 259,200

// Seconds
Duration::second();
Duration::seconds(int $seconds);

// Minutes
Duration::minute();
Duration::minutes(int $minutes);

// Hours
Duration::hour();
Duration::hours(int $hours);

// Days
Duration::day();
Duration::days(int $days);

// Weeks
Duration::week();
Duration::weeks(int $weeks);

$duration = Duration::week();

$duration->inSeconds(); // 604,800
$duration->inMinutes(); // 10,080
$duration->inHours();   // 168
$duration->inDays();    // 7
$duration->inWeeks();   // 1

// In some configuration file...
'cache_ttl' => Duration::days(2)->inSeconds(),