PHP code example of poldixd / human-readable-time

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

    

poldixd / human-readable-time example snippets


$datetime = \Carbon\Carbon::parse('2021-05-05 10:30:00')->subMinutes(15);

<x:human-readable-time :datetime="$datetime" />

$datetime = \Carbon\Carbon::parse('2021-05-05 10:30:00')->subMinutes(90);

<x:human-readable-time :datetime="$datetime" />

$datetime = \Carbon\Carbon::parse('2021-05-05 10:30:00')->subMinutes(120);

<x:human-readable-time :datetime="$datetime" human-until="-3 hours" />
html
<!-- Output -->
<time datetime="2021-05-05 09:00:00">2021-05-05 09:00:00</time>
html
<!-- Output -->
<time datetime="2021-05-05 09:00:00">2 hour before</time>