PHP 将时间戳转换为大写日期

php将时间戳转换为大写日期
    public function dateTimeToUpper($stamp, $type)
    {
        $year = str_split(date('Y', $stamp));
        $month = intval(date('m', $stamp));
	    //$day = intval(date('d', $stamp));

        $chars = array(
            0 => ['〇', '零'],
            1 => ['一', '壹'],
            2 => ['二', '贰'],
            3 => ['三', '叁'],
            4 => ['四', '肆'],
            5 => ['五', '伍'],
            6 => ['六', '陆'],
            7 => ['七', '柒'],
            8 => ['八', '捌'],
            9 => ['九', '玖'],
            10 => ['十', '拾'],
            11 => ['十一', '拾壹'],
            12 => ['十二', '拾贰'],
            13 => ['十三', '拾叁'],
            14 => ['十四', '拾肆'],
            15 => ['十五', '拾伍'],
            16 => ['十六', '拾陆'],
            17 => ['十七', '拾柒'],
            18 => ['十八', '拾捌'],
            19 => ['十九', '拾玖'],
            20 => ['二十', '贰拾'],
            21 => ['二十一', '贰拾壹'],
            22 => ['二十二', '贰拾贰'],
            23 => ['二十三', '贰拾叁'],
            24 => ['二十四', '贰拾肆'],
            25 => ['二十五', '贰拾伍'],
            26 => ['二十六', '贰拾陆'],
            27 => ['二十七', '贰拾柒'],
            28 => ['二十八', '贰拾捌'],
            29 => ['二十九', '贰拾玖'],
            30 => ['三十', '叁拾'],
            31 => ['三十一', '叁拾壹'],
        );
        $date = '';
        foreach ($year as $y) {
            $date .= $chars[$y][$type];
        }
        $date .= '年';
        $date .= $chars[$month][$type] . '月';
		//$date .= $chars[$day][$type] . '日';
        return $date;
    }

	echo $this->dateTimeToUpper(time(), 0);  //二〇二三年〇一月
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值