您好,欢迎访问一九零五行业门户网

php 时隔日期工具类

php 时间日期工具类
1582), century not-divisible by 400 is not leap else if ($year > 1582 && $year % 100 == 0 ) return false; return true; } /** * fix 2-digit years. works for any century. * assumes that if 2-digit is more than 30 years in future, then previous century. * @param integer $y year * @return integer change two digit year into multiple digits */ protected static function digitcheck($y) { if ($y 50) { $c1 = $century + 1; $c0 = $century; } else { $c1 = $century; $c0 = $century - 1; } $c1 *= 100; // if 2-digit year is less than 30 years in future, set it to this century // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. if (($y + $c1) 59 || $m 59 || $s = 0 && $timearr [0] = 0 && $timearr [1] = 0 && $timearr [2] public static function getweekday($date, $separator = -) { //计算出给出的日期是星期几 $datearr = explode ($separator, $date); return date ( w, mktime ( 0, 0, 0, $datearr [1], $datearr [2], $datearr [0] ) ); } public static function floortime($seconds) { //让日期显示为:xx天xx年以前 $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 ); } public static function transdatetochs($date) { if (empty ( $date )) return '今日'; $y = date ( 'y', strtotime ( $date ) ); $m = date ( 'm', strtotime ( $date ) ); $d = date ( 'd', strtotime ( $date ) ); return $y . '年' . $m . '月' . $d . '日'; } // 08/31/2004 => 2004-08-31 public static function transdateui($datestr, $type = 'y-m-d') { if ($datestr == null) return null; $target = $datestr; $arr_date = preg_split ( /\//, $target ); $monthstr = $arr_date [0]; $daystr = $arr_date [1]; $yearstr = $arr_date [2]; $result = date ( $type, mktime ( 0, 0, 0, $monthstr, $daystr, $yearstr ) ); return $result; } // 12/20/2004 10:55 am => 2004-12-20 10:55:00 public static function transdatetimeui($datestr, $type = 'y-m-d h:i:s') { if ($datestr == null) return null; $target = $datestr; $arr_date = preg_split ( /\/|\s|:/, $target ); $monthstr = $arr_date [0]; $daystr = $arr_date [1]; $yearstr = $arr_date [2]; $hourstr = $arr_date [3]; $minutesstr = $arr_date [4]; $result = date ( $type, mktime ( $hourstr, $minutesstr, 0, $monthstr, $daystr, $yearstr ) ); return $result; } // 2004-08-31 => 08/31/2004 public static function transdatedb($datestr, $type = 'm/d/y') { if ($datestr == null) return null; if ($datestr == '0000-00-00') return null; $target = $datestr; $arr_date = preg_split ( /-/, $target ); $monthstr = $arr_date [1]; $daystr = $arr_date [2]; $yearstr = $arr_date [0]; $result = date ( $type, mktime ( 0, 0, 0, $monthstr, $daystr, $yearstr ) ); return $result; } // 2004-08-31 10:55:00 => 12/20/2004 10:55 am public static function transdatetimedb($datestr, $type = 'm/d/y h:i a') { if ($datestr == null) return null; $target = $datestr; $arr_date = preg_split ( /-|\s|:/, $target ); $monthstr = $arr_date [1]; $daystr = $arr_date [2]; $yearstr = $arr_date [0]; $hourstr = $arr_date [3]; $minutesstr = $arr_date [4]; $secondstr = $arr_date [5]; $result = date ( $type, mktime ( $hourstr, $minutesstr, $secondstr, $monthstr, $daystr, $yearstr ) ); return $result; }}?>
?
其它类似信息

推荐信息