PHP code example of philippwitzmann / date-time-handler

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

    

philippwitzmann / date-time-handler example snippets


$year  = 2000;
$month = 12;
$day   = 30;

$hours    = 20;
$minutes  = 58;
$seconds  = 13;

$timeZone = new DateTimeZone('Europe/Berlin');

$dateTimeHandler = new DateTimeHandler(
    $year, $month, $day, $hours, $minutes, $seconds, $timeZone
);

$dateTimeHandler = new DateTimeHandler();

$dateTimeHandler = new DateTimeHandler(
            $year, $month, $day, $hours, $minutes, $seconds, $timeZone
        );

$date                  = new Date($year + 1, $month, $day);
$time                  = new Time($hours, $minutes, $seconds);
$dateTimeToDiffAgainst = new DateTime(
    $date, $time, $timeZone
);

$dateInverval = $dateTimeHandler->diff($dateTimeToDiffAgainst);

$dateTimeHandler = new DateTimeHandler();
$dateTimeHandler->setTestNow(); //freezes time

$dateTimeHandler->getTime(); // returns the Time, setTestNow() was called at.
bash
php vendor/bin/phpunit tests/ --configuration=config/phpunit.xml