1. Go to this page and download the library: Download magroski/time-buddy 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/ */
magroski / time-buddy example snippets
# Default
$time = new Time();
# From unix timestamp
$time = Time::createFromUnixTstamp(time());
# From DateTime
$dateTime = new \DateTime();
$time = Time::createFromDateTime($dateTime);
# From DateTimeImmutable
$immutable = new \DateTimeImmutable();
$time = new Time($immutable);
$firstTime = new Time();
$secondTime = $firstTime->add(100);
$thirdTime = $firstTime->subtract(100);
$time = new Time();
$time->format('d F Y'); # 20 May 2019
$time->setLocale('pt_BR');
$time->format('d F Y'); # 20 Maio 2019
$time = new Time();
$laterTime = new Time();
# From Time
$interval = $time->diff($laterTime);
# Staticaly
$interval = DateInterval::createFromTime($time, $laterTime);
# Staticaly from a single time
$interval = DateInterval::createFromTime($time); # Second argument is current time
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.