PHP code example of szalayk / datehuman

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

    

szalayk / datehuman example snippets



Szalayk\DateHuman\DateHuman;

$dh = new DateHuman('hu');
echo $dh->diff('2025-11-01 14:00:00'); // "2 napja"
echo $dh->diff('2025-11-05 14:00:00'); // "2 nap múlva"

$dh->setLanguage('it');
echo $dh->diff(strtotime('-3 hours'));  // "3 ore fa"