1. Go to this page and download the library: Download pwa/time-elapsed 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/ */
pwa / time-elapsed example snippets
$elapsed = new \Pwa\TimeElapsed($start);
'weeks_ago' => function ($weeks) {
if (floor($weeks) == 1) {
return 'a week ago';
} else {
return floor($weeks) . ' weeks ago';
}
},
$timezone = new \DateTimeZone("Europe/Stockholm");
$date = new \DateTime('2015-01-01 15:00:00', $timezone);
$elapsed = new TimeElapsed($date);
echo $elapsed->getElapsedTime(); // Between $date and $now = DateTime(null, $timezone);
// Output: a week ago
$localization = '/path/to/my_localization.php';
$elapsed->setLocalization($localization);
echo $elapsed->getElapsedTime();
// Output: one week ago
$localization = '/path/to/my_french_localization.php';
$elapsed->setLocalization($localization);
echo $elapsed->getElapsedTime();
// Output: Il ya 1 semaine
$start = new \DateTime('2015-01-01 15:00:00', $timezone);
$end = new \DateTime('2015-01-01 15:00:05', $timezone);
$elapsed = new TimeElapsed($start, end);
echo $elapsed->getElapsedTime();
// Output: a few seconds ago
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.