PHP code example of iarcadia / time
1. Go to this page and download the library: Download iarcadia/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/ */
iarcadia / time example snippets
$time = new Time;
$time = Time::create();
// true
new Time(56400) === Time::create(56400)
// true
new Time(0, 0, 56, 400) === Time::create(0, 0, 56, 400)
// true
new Time(56400) === Time::create(0, 0, 56, 400)
/**
* @param int|float $h - Hours
* @param int|float $i - Minutes
* @param int|float $s - Seconds
* @param int|float $v - Milliseconds
*
* @return iarcadia\time\Time
*/
$time = Time::create(17, 19, 0, 0);
$time = Time::create(0, 45, 12, 476);
/**
* @param int|float $int_or_float = 0 - Starting timestamp
*
* @return iarcadia\time\Time
*/
$time = Time::create(2712476)
/**
* @param string $format = '-h\h iim ss\s vvv'
*
* @return string
*/
$time = Time::create(1, 56, 4, 235);
// Write 1h 56m 04s 235
echo $time->format();
echo $time;
// Writes 1:56:04.235
echo $time->format('h:ii:ss.vvv');
// Writes 4 seconds and 235 ms
echo $time->format('s \se\con\d\s an\d vvv m\s');
// Write 04.2
echo $time->format('ss.d');
$time = Time::create(2, 12, 32, 489);
// Write 2
echo $time->getHours();
echo $time->hours;
// Write 2.20
echo $time->getTotalHours();
echo $time->total_hours;
// Write 12
echo $time->getMinutes();
echo $time->minutes;
// Write 132.54
echo $time->getTotalMinutes();
echo $time->total_minutes;
// Write 32
echo $time->getSeconds();
echo $time->seconds;
// Write 7952.48
echo $time->getTotalSeconds();
echo $time->total_seconds;
// Write 4
echo $time->getTenthOfSeconds();
echo $time->tenth_of_seconds;
// Write 79524.89
echo $time->getTotalTenthOfSeconds();
echo $time->total_tenth_of_seconds;
// Write 48
echo $time->getHundredthOfSeconds();
echo $time->hundredth_of_seconds;
// Write 795248.9
echo $time->getTotalHundredthOfSeconds();
echo $time->total_hundredth_of_seconds;
// Write 489
echo $time->getMilliseconds();
echo $time->milliseconds;
// Write 7952489
echo $time->getTotalMilliseconds();
echo $time->total_milliseconds;
$time = Time::create(2, 12, 32, 489);
// Write 1h 30m 00s 000
$time->setTotalHours(1.5);
$time->total_hours = 1.5;
echo $time;
// Write 0h 30m 15s 000
$time->setTotalMinutes(30.25);
$time->total_minutes = 30.25;
echo $time;
// Write 0h 01m 15s 000
$time->setTotalSeconds(75);
$time->total_seconds = 75;
echo $time;
// Write 0h 00m 48s 600
$time->setTotalTenthOfSeconds(486);
$time->total_tenth_of_seconds = 486;
echo $time;
// Write 0h 01m 29s 610
$time->setTotalHundredthOfSeconds(8961);
$time->total_hundredth_of_seconds = 8961;
echo $time;
// Write 0h 02m 05s 658
$time->setTotalMilliseconds(125658);
$time->total_milliseconds = 125658;
echo $time;
// Write -1h 35m 30s 210
$time = Time::create(-5703210);
echo $time;
// Write 2h 49m 23s 486
$time = Time::create(60000);
$time
->addHours(2)
->addMinutes(48)
->addSeconds(23)
->addMilliseconds(486);
echo $time;
// Write 0h 02m 15s 000
$time1 = Time::create(60000);
$time2 = Time::create(85000);
$time1->addFromTime($time2);
echo $time;
// Write 0h 01m 00s 000
$time1->subFromTime($time2);
echo $time;
// Write 0h 02m 15s 154
$time1 = Time::create(60000);
$time2 = Time::create(85000);
$time1->add($time2, 154);
echo $time;
// Write 0h 00m 00s 000
$time1->sub(0, 2, 15, 154);
echo $time;
$time1 = Time::create(1, 50, 0, 0);
$time2 = Time::create(3, 0, 24, 0);
// false
$time1->isEqualTo($time2);
$time1->eq($time2);
// true
$time1->isNotEqualTo($time2);
$time1->neq($time2);
// false
$time1->isGreaterThan($time2);
$time1->gt($time2);
$time1->isGreaterThanOrEqualTo($time2);
$time->gteq($time2);
// true
$time1->isLessThan($time2);
$time1->lt($time2);
$time1->isLessThanOrEqualTo($time2);
$time->lteq($time2);