PHP code example of jmf / time

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

    

jmf / time example snippets




use Jmf\Time\Clock;

$clock = new Clock();

// Will output something like "2020-01-23"
echo $clock->getDateTime()->format('Y-m-d');

// Will output something like "2020-01-23"
echo $clock->getDateString();

// Will output something like "15:16:17"
echo $clock->getTimeString();

// Will output something like "2020-01-23 15:16:17"
echo $clock->getDateTimeString();

// Will output something like "123456789"
echo $clock->getTimestamp();

// Will output something like "123456789.0123"
echo $clock->getMicrotime();



use Jmf\Time\Timer;

$timer = new Timer();

sleep(1);

// Will output something like "0.0"
echo $timer->getElapsed();

$timer->start();

sleep(1);

// Will output something like "1.0023456"
echo $timer->getElapsed();

sleep(1);

$timer->stop();

sleep(1);

// Will output something like "2.0034567"
echo $timer->getElapsed();

$timer->restart();

sleep(1);

// Will output something like "1.0023456"
echo $timer->getElapsed();

sleep(1);

// Will output something like "2.0034567"
echo $timer->getElapsed();

$timer->reset();

sleep(1);

// Will output something like "0.0"
echo $timer->getElapsed();