years // -> months // -> days // -> total_months // -> total_days // //// if (!function_exists('date_difference')) { //// function date_difference($start_date,$anniversary_date="") { //// list($year,$month,$day) = explode("-",$start_date); //// //// if ($anniversary_date) list($year1,$month1,$day1) = explode("-",$anniversary_date); //// else list($year1,$month1,$day1) = explode("-",date("Y-m-d",time())); //// //// $year_diff = $year1 - $year; //// $month_diff = $month1 - $month; //// $day_diff = $day1 - $day; //// //// if ($month_diff < 0) { //// $year_diff--; //// $month_diff = 12 + $month_diff; //// } //// elseif (($month_diff==0) && ($day_diff < 0)) { //// $year_diff--; //// } //// //// return $year_diff; //// } ////} // // html // - added 2007-05-09 // // Convert a string of text so that all applicable characters are HTML entities // if (!function_exists('html')) { function html($text) { return htmlentities(stripslashes($text)); } } // // parseEmailText // - added 2007-05-09 // // Perform value replacement on all variables in a block of text. The set of // values to replace is passed as an array and the array indices are the variables.. // if (!function_exists('parseEmailText')) { function parseEmailText($message, $vals) { $msg = $message; foreach ($vals as $name => $value) { $msg = eregi_replace("\[{$name}\]", $value, $msg); $msg = eregi_replace("\{{$name}\}", $value, $msg); } return nl2br(trim($msg)); } } // // timeToEnglish // - added 2007-05-09 // // Convert a time value (seconds since midnight) to an English value of hours and minutes // if (!function_exists('timeToEnglish')) { function timeToEnglish($time, $hr24=0, $ampm=0) { $hr = floor($time / 60); if (!$hr24) { $hr = $hr % 12; if ($hr == 0) $hr = 12; } else { if ($hr < 10) $hr = "0" . $hr; } $min = $time % 60; if ($min < 10) $min = "0" . $min; $t = "{$hr}:{$min}"; if ($ampm) { if ($time < 12*60) { $t .= " am"; } else { $t .= " pm"; } } return $t; } } ?>