PHP code example of bzrk / php-timeunit
1. Go to this page and download the library: Download bzrk/php-timeunit 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/ */
bzrk / php-timeunit example snippets
sleep(60*60*3); // 3 Hours
sleep(60*45); // 45 Minutes
$time = \time(); - (60*60*3);
TimeUnit::ofHours(3)->sleep();
TimeUnit::ofMinutes(45)->sleep();
TimeUnit::now()->minus(TimeUnit::ofMinutes(3));
function a(int $seconds) {
//whatever doing with the seconds
}
a(-123455);
a(1234);
function a(TimeUnit $time) {
//whatever doing with the seconds
}
a(TimeUnit::ofSeconds(12));
a(TimeUnit::ofSeconds(-12)); throws a InvalidArgumentException