PHP code example of dcarbone / gotime

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

    

dcarbone / gotime example snippets


use \DCarbone\Go\Time;

$d = new Time\Duration(5 * Time::Second);
// produces a Duration with an internal value of 5e9;

$d = Time::ParseDuration('5s');
// produces a Duration with an internal value of 5e9;

$dt = new \DateTime();
echo "{$dt->format('H:i:s')}\n";

$d = new Time\Duration(5 * Time::Second);
$dt->add($d->DateInterval());
echo "{$dt->format('H:i:s')}\n";

// 16:03:37
// 16:03:42

use DCarbone\Go\Time;

// Returns an instance of Time\Time with an internal time of the unix epoch 
$t = Time::New();

// Returns an instance of Time\Time with an internal time of whenever you constructed it. 
$t = Time::Now();