Permalink
Browse files

custom formats example

  • Loading branch information...
1 parent ec882eb commit 113f5a393ca6196dd8cb41a594701d59bb060b70 @cweiske cweiske committed May 10, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 examples/custom.php
View
@@ -0,0 +1,12 @@
+<?php
+require_once 'Date/HumanDiff.php';
+
+$dh = new Date_HumanDiff();
+$dh->clearFormats();
+$dh->addFormat(5 * 60, '< 5m', 1);
+$dh->addFormat(86400, '%d x 10 minutes ago', 10 * 60);
+$dh->addFormat(PHP_INT_MAX, 'long long ago', 1);
+
+echo $dh->get(time() - 60 * 4) . "\n"; //shows "< 5m"
+echo $dh->get(time() - 60 * 40) . "\n"; //shows "4 x 10 minutes ago"
+?>

0 comments on commit 113f5a3

Please sign in to comment.