title: PHP截取中文字符串和日期字符串截取
author: Love02xp
date: 2023-09-02 11:04:17
category: [编程代码]
tags: [PHP,代码,学习]
一、中文截取:mb_substr()
mb_substr( $str, $start, $length, $encoding )
$str,需要截断的字符串
$start,截断开始处,起始处为0
$length,要截取的字数
$encoding,网页编码,如utf-8,GB2312,GBK
二、截取日期
$time = '2015-05-22 12:10:00';
echo date('Y-m-d',strtotime($time));
输出 2015-05-22;