PHP code example of iserv / zeit

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

    

iserv / zeit example snippets


use IServ\Library\Zeit\Clock\FixedClock;
use IServ\Library\Zeit\Zeit;

$now = Zeit::now();
printf("It is %s o'clock", $now->format('H'));

Zeit::setClock(FixedClock::fromString('2021-04-23 12:00:00'));

$now = Zeit::now();
printf("It is %s o'clock", $now->format('H'));
 // Will print 12 o'clock

use IServ\Library\Zeit\Date;
use IServ\Library\Zeit\Time;

$date = Date::fromParts(2021, 4, 23);
echo $date->getValue();
// will print the normalized string representation "2021-04-23"

$time = Time::fromParts(10, 37); // The third parameter for seconds is optional and defaults to zero 
echo $time->getValue();
// will print the normalized string representation "10:37:00"

// You can merge a Date and a Time to \DateTimeImmutable
$dateTime = $date->withTime($time);
echo $dateTime->format('Y:m:d H:i:s');
// will print "2021-04-23 10:37:00"