PHP code example of oneletter / human-date

1. Go to this page and download the library: Download oneletter/human-date 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/ */

    

oneletter / human-date example snippets




use OneLetter\Common\HumanDate;

$humanDate = new HumanDate('UTC', 'en');

$humanDate->format(new \DateTime('-1 day')); // yesterday at 3:18 pm
$humanDate->format(new \DateTime('-5 hours')); // today at 10:18 am
$humanDate->format(new \DateTime('-50 minutes')); // one hour ago
$humanDate->format(new \DateTime('-4 seconds')); // just now

$humanDate->format(new \DateTime('+1 day')); // tomorrow at 3:18 pm
$humanDate->format(new \DateTime('+5 hours')); // today at 8:18 pm
$humanDate->format(new \DateTime('+50 minutes')); // one hour ago
$humanDate->format(new \DateTime('+4 seconds')); // just now