PHP code example of jimmiw / php-time-ago

1. Go to this page and download the library: Download jimmiw/php-time-ago 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/ */

    

jimmiw / php-time-ago example snippets


composer 

$timeAgo = new Westsworld\TimeAgo();
echo $timeAgo->inWords(new DateTime("2010-01-10 23:05:00"));

$timeAgo = new Westsworld\TimeAgo();
echo $timeAgo->inWordsFromStrings("2010/1/10 23:05:00");

$timeAgo = new Westsworld\TimeAgo();
// NOTE: this is actually deprecated, since DateTime does the same. Still works though :)
$dateDifferenceArray =  $timeAgo->dateDifference("2017-03-02 07:53:00", "2017-03-02 07:53:01");

$myLang = new \Westsworld\TimeAgo\Translations\Da();

$timeAgo = new Westsworld\TimeAgo($myLang); // default language is en (english)
echo $timeAgo->inWords("2010/1/10 23:05:00");