将Y-m-d转换为Y年m月d日
自己编写的,不能直接套用,理解后可自行变化:
$var=explode(' ',$res['act_starting']);
$var1=$var[0];
$time=explode('-',$var1);
if($time[1]<10)
{
$time[1] = str_replace("0", "", $time[1]);
}else
{
$time[1]=$time[1];
}
if($time[2]<10)
{
$time[2] = str_replace("0", "", $time[2]);
}else
{
$time[2]=$time[2];
}
$json['date']=$time[0]."年".$time[1]."月".$time[2]."日";
$time = date("Y-m-d", $time); $var=explode(' ',$time); $var1=$var[0]; $time=explode('-',$var1); if($time[1]<10){ $time[1] = str_replace("0", "", $time[1]); }else{ $time[1]=$time[1]; } if($time[2]<10){ $time[2] = str_replace("0", "", $time[2]); }else{ $time[2]=$time[2]; } $new_time = $time[0]."年".$time[1]."月".$time[2]."日";
封装后
/** * 拼装年月日 */ public function rn_date($time){ $var=explode(' ',$time); $var1=$var[0]; $time=explode('-',$var1); if($time[1]<10){ $time[1] = str_replace("0", "", $time[1]); }else{ $time[1]=$time[1]; } if($time[2]<10){ $time[2] = str_replace("0", "", $time[2]); }else{ $time[2]=$time[2]; } $new_time =$time[0]."年". $time[1]."月".$time[2]."日"; return $new_time; }
作者:子钦加油
出处:https://www.cnblogs.com/zmdComeOn/
个性签名:努力生活,努力走路
阿里云拼团:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
腾讯云三月采购计划特价:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年
出处:https://www.cnblogs.com/zmdComeOn/
个性签名:努力生活,努力走路
阿里云拼团:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
腾讯云三月采购计划特价:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年