php日期数字转为汉字格式

$str = '2016-11-23';
function setDateCn($str){
    $month = str_split(date('m',strtotime($str)));
    $month = implode('十', $month);
    $month = str_replace('十0', '十', $month);
    $month = str_replace('1十', '十', $month);
    $month = str_replace('0十', '', $month);

    $day = str_split(date('d',strtotime($str)));
    $day = implode('十', $day);
    $day = str_replace('十0', '十', $day);
    $day = str_replace('1十', '十', $day);
    $day = str_replace('0十', '', $day);

    return str_replace(str_split('0123456789'), str_split('〇一二三四五六七八九',3), date('Y',strtotime($str)).'年'.$month.'月'.$day).'日'; 
}

Tags: PHP

仅有一条评论

  1. 解决其他网站贴出的代码中,转换04为十四的问题

添加新评论