$v) { $v = preg_replace("/^0{1,}/", '', trim($v)); if ($v == '') { $dt[$k] = 0; } } $mt = mktime($dt[3], $dt[4], $dt[5], $dt[1], $dt[2], $dt[0]); if (!empty($mt)) { return $mt; } else { return time(); } } } /** * 减去时间 * * @param int $ntime 当前时间 * @param int $ctime 减少的时间 * @return int */ if (!function_exists('SubDay')) { function SubDay($ntime, $ctime) { $dayst = 3600 * 24; $cday = ceil(($ntime - $ctime) / $dayst); return $cday; } } /** * 增加天数 * * @param int $ntime 当前时间 * @param int $aday 增加天数 * @return int */ if (!function_exists('AddDay')) { function AddDay($ntime, $aday) { $dayst = 3600 * 24; $oktime = $ntime + ($aday * $dayst); return $oktime; } } /** * 返回格式化(Y-m-d H:i:s)的是时间 * * @param int $mktime 时间戳 * @return string */ if (!function_exists('GetDateTimeMk')) { function GetDateTimeMk($mktime) { return MyDate('Y-m-d H:i:s', $mktime); } } /** * 返回格式化(Y-m-d)的日期 * * @param int $mktime 时间戳 * @return string */ if (!function_exists('GetDateMk')) { function GetDateMk($mktime) { if ($mktime == "0") return "暂无"; else return MyDate("Y-m-d", $mktime); } } /** * 将时间转换为距离现在的精确时间 * * @param int $seconds 秒数 * @return string */ if (!function_exists('FloorTime')) { function FloorTime($seconds) { $times = ''; $days = floor(($seconds / 86400) % 30); $hours = floor(($seconds / 3600) % 24); $minutes = floor(($seconds / 60) % 60); $seconds = floor($seconds % 60); if ($seconds >= 1) $times .= $seconds.'秒'; if ($minutes >= 1) $times = $minutes.'分钟 '.$times; if ($hours >= 1) $times = $hours.'小时 '.$times; if ($days >= 1) $times = $days.'天'; if ($days > 30) return false; $times .= '前'; return str_replace(" ", '', $times); } }