Something like this, but this is not perfect..  The mktime seem to work only
for Unix/Linux and not work for Windows.

--snip--
function dateDiff($input_date)
{
   //MSG #1 - Parameter1 must be in this date format --> "mm/dd/yyyy"
   //MSG #2 - This script does not include fix for the leap year...
   $UserInput = explode("/", $input_date);

   $UserInputMonth = $UserInput[0];
   $UserInputDay = $UserInput[1];
   $UserInputYear = $UserInput[2];

   $clockDate = mktime(0,0,0,date("m"),date("d"),date("Y"));
   $inputDate = mktime(0,0,0,$UserInputMonth,$UserInputDay,$UserInputYear);

   $Days = (($clockDate - $inputDate) / (24 * 3600));
   $Days = round($Days);

   return $Days;
}
--snip--

"Richard Davey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I'm just wondering if anyone knows of a class/function (or easy way)
> to do the following:
>
> At the moment I display dates like this:
>
> Last message received: 30th Nov 2003 16:07
>
> This is fine, but I would like to make them more friendly like so:
>
> Last message received: Yesterday, 16:07
>
> I would ideally like to have the ranges "Today, Yesterday, This Week, Last
> Week" and beyond that I'll use the method above.
>
> I know how to actually do this from a code point of view, but think it
> must be a quite general sort of task and am all for not re-inventing
> the wheel here if someone knows/has a quick way to do this?
>
> -- 
> Best regards,
>  Richard                          mailto:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to