<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head><body><code><span style="color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 187);"><?php
<br></span><span style="color: rgb(255, 128, 0);">/*
<br> * JavaScript Pretty Date
<br> * Copyright (c) 2008 John Resig (jquery.com)
<br> * Licensed under the MIT license.
<br> */
<br>
<br>// Ported to PHP >= 5.1 by Zach Leatherman (zachleat.com)
<br>// Slight modification denoted below to handle months and years.
<br></span><span style="color: rgb(0, 119, 0);">class </span><span style="color: rgb(0, 0, 187);">Date_Difference
<br></span><span style="color: rgb(0, 119, 0);">{
<br> public static function </span><span style="color: rgb(0, 0, 187);">getStringResolved</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$date</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(0, 0, 187);">$compareTo </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">NULL</span><span style="color: rgb(0, 119, 0);">)
<br> {
<br> if(!</span><span style="color: rgb(0, 0, 187);">is_null</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$compareTo</span><span style="color: rgb(0, 119, 0);">)) {
<br> </span><span style="color: rgb(0, 0, 187);">$compareTo </span><span style="color: rgb(0, 119, 0);">= new </span><span style="color: rgb(0, 0, 187);">DateTime</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$compareTo</span><span style="color: rgb(0, 119, 0);">);
<br> }
<br> return </span><span style="color: rgb(0, 0, 187);">self</span><span style="color: rgb(0, 119, 0);">::</span><span style="color: rgb(0, 0, 187);">getString</span><span style="color: rgb(0, 119, 0);">(new </span><span style="color: rgb(0, 0, 187);">DateTime</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$date</span><span style="color: rgb(0, 119, 0);">), </span><span style="color: rgb(0, 0, 187);">$compareTo</span><span style="color: rgb(0, 119, 0);">);
<br> }
<br>
<br> public static function </span><span style="color: rgb(0, 0, 187);">getString</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">DateTime $date</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(0, 0, 187);">DateTime $compareTo </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">NULL</span><span style="color: rgb(0, 119, 0);">)
<br> {
<br> if(</span><span style="color: rgb(0, 0, 187);">is_null</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$compareTo</span><span style="color: rgb(0, 119, 0);">)) {
<br> </span><span style="color: rgb(0, 0, 187);">$compareTo </span><span style="color: rgb(0, 119, 0);">= new </span><span style="color: rgb(0, 0, 187);">DateTime</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'now'</span><span style="color: rgb(0, 119, 0);">);
<br> }
<br> </span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">$compareTo</span><span style="color: rgb(0, 119, 0);">-></span><span style="color: rgb(0, 0, 187);">format</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'U'</span><span style="color: rgb(0, 119, 0);">) - </span><span style="color: rgb(0, 0, 187);">$date</span><span style="color: rgb(0, 119, 0);">-></span><span style="color: rgb(0, 0, 187);">format</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">'U'</span><span style="color: rgb(0, 119, 0);">);
<br> </span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">floor</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">/ </span><span style="color: rgb(0, 0, 187);">86400</span><span style="color: rgb(0, 119, 0);">);
<br>
<br> if(</span><span style="color: rgb(0, 0, 187);">is_nan</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$dayDiff</span><span style="color: rgb(0, 119, 0);">) || </span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">0</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">;
<br> }
<br>
<br> if(</span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">== </span><span style="color: rgb(0, 0, 187);">0</span><span style="color: rgb(0, 119, 0);">) {
<br> if(</span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">60</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(221, 0, 0);">'Just now'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">120</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(221, 0, 0);">'1 minute ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">3600</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(0, 0, 187);">floor</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$diff</span><span style="color: rgb(0, 119, 0);">/</span><span style="color: rgb(0, 0, 187);">60</span><span style="color: rgb(0, 119, 0);">) . </span><span style="color: rgb(221, 0, 0);">' minutes ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">7200</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(221, 0, 0);">'1 hour ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$diff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">86400</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(0, 0, 187);">floor</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$diff</span><span style="color: rgb(0, 119, 0);">/</span><span style="color: rgb(0, 0, 187);">3600</span><span style="color: rgb(0, 119, 0);">) . </span><span style="color: rgb(221, 0, 0);">' hours ago'</span><span style="color: rgb(0, 119, 0);">;
<br> }
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">== </span><span style="color: rgb(0, 0, 187);">1</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(221, 0, 0);">'Yesterday'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">7</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">. </span><span style="color: rgb(221, 0, 0);">' days ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">== </span><span style="color: rgb(0, 0, 187);">7</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(221, 0, 0);">'1 week ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">< (</span><span style="color: rgb(0, 0, 187);">7</span><span style="color: rgb(0, 119, 0);">*</span><span style="color: rgb(0, 0, 187);">6</span><span style="color: rgb(0, 119, 0);">)) { </span><span style="color: rgb(255, 128, 0);">// Modifications Start Here
<br> // 6 weeks at most
<br> </span><span style="color: rgb(0, 119, 0);">return </span><span style="color: rgb(0, 0, 187);">ceil</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$dayDiff</span><span style="color: rgb(0, 119, 0);">/</span><span style="color: rgb(0, 0, 187);">7</span><span style="color: rgb(0, 119, 0);">) . </span><span style="color: rgb(221, 0, 0);">' weeks ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } elseif(</span><span style="color: rgb(0, 0, 187);">$dayDiff </span><span style="color: rgb(0, 119, 0);">< </span><span style="color: rgb(0, 0, 187);">365</span><span style="color: rgb(0, 119, 0);">) {
<br> return </span><span style="color: rgb(0, 0, 187);">ceil</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$dayDiff</span><span style="color: rgb(0, 119, 0);">/(</span><span style="color: rgb(0, 0, 187);">365</span><span style="color: rgb(0, 119, 0);">/</span><span style="color: rgb(0, 0, 187);">12</span><span style="color: rgb(0, 119, 0);">)) . </span><span style="color: rgb(221, 0, 0);">' months ago'</span><span style="color: rgb(0, 119, 0);">;
<br> } else {
<br> </span><span style="color: rgb(0, 0, 187);">$years </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0, 187);">round</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$dayDiff</span><span style="color: rgb(0, 119, 0);">/</span><span style="color: rgb(0, 0, 187);">365</span><span style="color: rgb(0, 119, 0);">);
<br> return </span><span style="color: rgb(0, 0, 187);">$years </span><span style="color: rgb(0, 119, 0);">. </span><span style="color: rgb(221, 0, 0);">' year' </span><span style="color: rgb(0, 119, 0);">. (</span><span style="color: rgb(0, 0, 187);">$years </span><span style="color: rgb(0, 119, 0);">!= </span><span style="color: rgb(0, 0, 187);">1 </span><span style="color: rgb(0, 119, 0);">? </span><span style="color: rgb(221, 0, 0);">'s' </span><span style="color: rgb(0, 119, 0);">: </span><span style="color: rgb(221, 0, 0);">''</span><span style="color: rgb(0, 119, 0);">) . </span><span style="color: rgb(221, 0, 0);">' ago'</span><span style="color: rgb(0, 119, 0);">;
<br> }
<br> }
<br>}</span>
</span>
</code></body></html>