简单记录下
public function formatDate($date_text, $year_unit = '年', $month_unit = '月', $day_unit = '天')
{
$year = 0;
$month = 0;
$day = 0;
$status = true;
$msg = '参数不正确';
$explode_year = explode($year_unit,$date_text);
$explode_month = explode($month_unit,$date_text);
$explode_day = explode($day_unit,$date_text);
$count1 = count($explode_year);
$count2 = count($explode_month);
$count3 = count($explode_day);
if (($count1 == 2) && ($count2 == 2) && ($count3 == 2)) {
$year = $explode_year[0];
$month = explode($year.$year_unit,$explode_month[0])[1];
$day = explode($year.$year_unit.$month.$month_unit,$explode_day[0])[1];
$status = true;
$msg = '格式化成功';
}
$data = ['year' => $year, 'month' => $month, 'day' => $day];
return ['status' => $status,'data' => $data,'msg' => $msg];
}