1. Basic usage: Getting a
    human readable time
    difference
  2. Using translations
  3. Generating HTML

Basic usage: Getting a human readable time difference

Just include the Date/HumanDiff.php file, instantiate a Date_HumanDiff object and run get() on it.

<?php
require_once 'Date/HumanDiff.php';
$dh = new Date_HumanDiff();
echo 
$dh->get(time() - 60) . "\n";
//prints out "5 minutes ago"
?>

get() accepts two parameters: The timestamp and the reference time. If the reference time is not provided, the current time is used. Both parameters may be unix timestamps, DateTime objects as well as strings that can be converted to a unix timestamp with strtotime.

The difference between timestamp and reference time is then converted into a human readable string.

Date_HumanDiff (Previous) Using translations (Next)
Last updated: Thu, 30 Oct 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.