新手求助-findall的结果集的 字符截取

#1 chenkexc

第一次用sp。
对findall的数组结果。应该如何截取求助。
比如:
$suibian=spClass("suibian")
$conditions = "id>1";
$this->results= $suibian->findall($conditions,null,null,"0,5");


这样,取得的results数组中,比如有有ID,time这些字段。。

我要在smarty中显示time。比如原纪录是:2010-02-02 14:00:00
但是,我只需要显示 02-02 14:00  应该怎么截取额。

smarty的 truncate 不能指定截取的顺序。。
要是用php的 substr mb_substr..岂不是更麻烦?

2011-05-25 15:47:10

#2 jake

可以试试replace和regex_replace,因为time类型的位置都是比较固定。空白替换掉不用就是了。

http://www.smarty.net/docsv2/en/

一般我们存这种字段,除非是比较强制的要求,不然一般用“时间戳”来存时间,INT(11)就可以。然后显示的时候,用PHP的date或者smarty的date_format都可以转换成很多种时间显示

http://www.smarty.net/docsv2/en/language.modifier.date.format.tpl

PS:请把这类的帖子发到“求助问答”区,谢谢!本贴稍候将转移到问答区!

2011-05-25 18:37:43