醉爱PHP

Smarty逼我要这样去显示日期

by admin on 四.22, 2009, under php

设计者说,页面中的月与日的日期显示没有前导0。例如:2009年4月22日 而并不能显示为 2009年04月22日

可smarty的date_format插件却没怎么也找不到月份没有前导0的。google之也没找出来。

折衷一下,只好这样做处理了。

$datetime|date_format:”%Y-%m-%d”|regex_replace:”(\d+)\-0*(\d+)\-0*(\d+)”:”\\1年\\2月\\3日”

呼~~~,搞定,收工!不过这样跑的程序真的好累。

:

1 Comment for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...