
php调用时截取和时间格式显示
在php调用中:".$newsArr['news_title']."这句怎么截取调用时只显示前8位,后面用...代替;".$newsArr['news_time']."这...
在php调用中:
".$newsArr['news_title']." 这句怎么截取调用时只显示前8位,后面用...代替 ;
".$newsArr['news_time']." 这句现在有显示到小时分秒,怎么只显示年月日
请具体些按我这格式写 展开
".$newsArr['news_title']." 这句怎么截取调用时只显示前8位,后面用...代替 ;
".$newsArr['news_time']." 这句现在有显示到小时分秒,怎么只显示年月日
请具体些按我这格式写 展开
3个回答
展开全部
可以先将时间转换下,然后重新将时间格式化显示:
echo date("Y-m-d", strtotime($newsArr['news_time']));
echo date("Y-m-d", strtotime($newsArr['news_time']));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
substr($newsArr['news_title'],0,8)."...";
substr($newsArr['news_time'],0,10);
substr($newsArr['news_time'],0,10);
追问
谢谢,只是用这调用截取字节的老是后面有两个乱码如:
这是一个中文��... 2012-09-28
追答
这个是字符集编码的问题,你数据库的字符集编码和在html的要一致,如果是uft-8的编码就在在html的head中加上 ,
gb2312的就加上
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
substr()
date("Y-m-d H:i:s")
date("Y-m-d H:i:s")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询