PHP code example of icecave / chrono

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

    

icecave / chrono example snippets


use Icecave\Chrono\Clock\SystemClock;

// Construct a new system clock ...
$clock = new SystemClock;

// Obtain a DateTime instance representing the current date and time ...
$now = $clock->localDateTime();

// Obtain a Date instance representing the current date ...
$today = $clock->localDate();

// Obtain the current time of day ...
$timeOfDay = $clock->localTime();

$nowUtc = $clock->utcDateTime();

$now = $clock->localDateTime();
$string = $now->format('Y-m-d H:i:s');

$dateTime = DateTime::fromUnixTime(1367823963);
$timestamp = $dateTime->unixTime();

use DateTime as NativeDateTime;
use Icecave\Chrono\DateTime;

$dateTime = DateTime::fromNativeDateTime(new NativeDateTime);
$nativeDateTime = $dateTime->nativeDateTime();