0 && $Levels>0) { if ($Years>1) { $Return .= $Years.' years'; } else { $Return .= $Years.' year'; } $Levels--; } if ($Months>0 && $Levels>0) { if ($Return!='') { $Return.=', '; } if ($Months>1) { $Return.=$Months.' months'; } else { $Return.=$Months.' month'; } $Levels--; } if ($Weeks>0 && $Levels>0) { if ($Return!="") { $Return.=', '; } if ($Weeks>1) { $Return.=$Weeks.' weeks'; } else { $Return.=$Weeks.' week'; } $Levels--; } if ($Days>0 && $Levels>0) { if ($Return!='') { $Return.=', '; } if ($Days>1) { $Return.=$Days.' days'; } else { $Return.=$Days.' day'; } $Levels--; } if ($Hours>0 && $Levels>0) { if ($Return!='') { $Return.=', '; } if ($Hours>1) { $Return.=$Hours.' hours'; } else { $Return.=$Hours.' hour'; } $Levels--; } if ($Minutes>0 && $Levels>0) { if ($Return!='') { $Return.=' and '; } if ($Minutes>1) { $Return.=$Minutes.' mins'; } else { $Return.=$Minutes.' min'; } $Levels--; } if($Return == '') { $Return = 'Just now'; } elseif (!isset($HideAgo)) { $Return .= ' ago'; } if ($Lowercase) { $Return = strtolower($Return); } if ($Span) { return ''.$Return.''; } else { return $Return; } } /* SQL utility functions */ function time_plus($Offset) { return date('Y-m-d H:i:s', time()+$Offset); } function time_minus($Offset, $Fuzzy = false) { if($Fuzzy) { return date('Y-m-d 00:00:00', time()-$Offset); } else { return date('Y-m-d H:i:s', time()-$Offset); } } function sqltime($timestamp = false) { if ($timestamp === false) { $timestamp = time(); } return date('Y-m-d H:i:s', $timestamp); } function validDate($DateString) { $DateTime = explode(" ", $DateString); if(count($DateTime) != 2) return false; list($Date, $Time) = $DateTime; $SplitTime = explode(":", $Time); if(count($SplitTime) != 3) return false; list($H, $M, $S) = $SplitTime; if($H != 0 && !(is_number($H) && $H < 24 && $H >= 0)) return false; if($M != 0 && !(is_number($M) && $M < 60 && $M >= 0)) return false; if($S != 0 && !(is_number($S) && $S < 60 && $S >= 0)) return false; $SplitDate = explode("-", $Date); if(count($SplitDate) != 3) return false; list($Y, $M, $D) = $SplitDate; return checkDate($M, $D, $Y); } ?>