PHP code example of dcaswel / time-converter

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

    

dcaswel / time-converter example snippets


//One day's worth of seconds
$ttl = 24 * 60 * 60;

use Dcaswel\TimeConverter\TimeConverter;

$ttl = TimeConverter::convert()->oneDay()->toSeconds();

TimeConverter::convert()->days(5)->toSeconds(); //432000
TimeConverter::convert()->years(2)->toMonths(); //24
TimeConverter::convert()->weeks(20)->toDays(); //140
...

TimeConverter::convert()->weeks(2)->days(5)->toDays(); //19

/**
 * Methods to set the time being converted 
 */
 
public function minutes(int $number)
public function hours(int $number)
public function days(int $number)
public function weeks(int $number)
public function months(int $number)
public function years(int $number)

/**
 * Methods to get the number you want to convert to
 */

public function toSeconds(): int|float
public function toMinutes(): int|float
public function toHours(): int|float
public function toDays(): int|float
public function toWeeks(): int|float
public function toMonths(): int|float
public function toYears(): int|float