espcms時間輸出格式自定義:月份顯示英文縮寫——修改php date返回值

/public/ectemplates/ectemplates_class.phpphp

605行數組

php date()能夠返回月份的數字,數組中用鍵值對列出英文縮寫詞輸出spa

function timeformat($time, $type = 3, $font = '-', $ddstr = 'Y') {
        $time = empty($time) ? time() : ((strstr($time, ':') || strstr($time, '-')) ? strtotime($time) : $time);
        //月份表
        $months = array(
            1 => 'Jan', 
            2 => 'Feb', 
            3 => 'Mar', 
            4 => 'Apr',
            5 => 'May',
            6 => 'Jun',
            7 => 'Jul',
            8 => 'Aug',
            9 => 'Sep',
            10 => 'Oct',
            11 => 'Nov',
            12 => 'Dec'

        );
        switch ($type) {
            case 1:
                $format = date('H:i:s', $time);
                break;
            case 2:
                $format = date('Y' . $font . 'm' . $font . 'd', $time);
                break;
            case 3:
                $format = date('Y' . $font . 'm' . $font . 'd H:i:s', $time);
                break;
            case 4:
                $format = date('Y' . $font . 'm' . $font . 'd H:i', $time);
                break;
            case 5:
                $format = date('m' . $font . 'd H:i', $time);
                break;
            case 6:
                $format = date('m' . $font . 'd', $time);
                break;
            case 7:
                $format = date('y' . $font . 'm' . $font . 'd', $time);
                break;
            case 8:
                $format = date('y' . $font . 'm' . $font . 'd H:i:s', $time);
                break;
            case 9:
                $format = date('y' . $font . 'm' . $font . 'd H:i', $time);
                break;
            case 10:
                $format = date($ddstr, $time);
                break;
            case M:        //返回月份的英文縮寫
                $format = date('m', $time);    
                //$format = $months[$format];
                $filename = 'file.txt';
                $format = (int)$format;
                $format = $months[$format];break;
            case m:
                $format = date('m', $time);    
                break;
            case d:
                $format = date('d', $time);
                break;
        }
        
        return $format;
    }
相關文章
相關標籤/搜索