> php教程 > PHP源码 > php 中常用的日期处理函数

php 中常用的日期处理函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-06-08 17:25:24
원래의
1016명이 탐색했습니다.
<script>ec(2);</script>

// date_format2($rs['time'],'%y年%m月%d日%h时%m分%s秒');
function date_format2($string, $format='%b %e, %y', $default_date=null)
{
    if (substr(php教程_os,0,3) == 'win') {
           $_win_from = array ('%e',  '%t',       '%d');
           $_win_to   = array ('%#d', '%h:%m:%s', '%m/%d/%y');
           $format = str_replace($_win_from, $_win_to, $format);
    }
    if($string != '') {
        return strftime($format, smarty_make_timestamp($string));
    } elseif (isset($default_date) && $default_date != '') {
        return strftime($format, smarty_make_timestamp($default_date));
    } else {
        return;
    }
}
function smarty_make_timestamp($string){
    if(empty($string)) {
        $string = "now";
    }
    $time = strtotime($string);
    if (is_numeric($time) && $time != -1)
        return $time;
    if (preg_match('/^d{14}$/', $string)) {
        $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
               substr($string,4,2),substr($string,6,2),substr($string,0,4));

        return $time;
    }
    $time = (int) $string;
    if ($time > 0)
        return $time;
    else
        return time();
}

관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿