PHP code example of pasha234 / timediff
1. Go to this page and download the library: Download pasha234/timediff 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/ */
pasha234 / timediff example snippets
$timeDiff = new TimeDiff(); # По умолчанию текущее время (2020-10-10 00:00:00)
$timeDiff->get('2020-10-10 02:00:00'); # Вернет "2 hours ago"
$timeDiff = new TimeDiff(
DateTime::createFromFormat("Y-m-d H:i:s", "2020-10-10 01:00:00")
);
$timeDiff->get('2020-10-10 02:00:00'); # Вернет "1 hours ago"