Time format conversion question & nbsp; 22:26:56 how to convert the above time format to 3 seconds ago or 3 days ago this Format Display Share to: more time format conversion question
22:26:56
How to convert the preceding time format to 3 seconds ago or 3 days ago
Share: More
------ Solution --------------------
Http://www.baidu.com? Wd = Smarty % E6 % A8 % A1 % E6 % 9D % BF % E5 % 87% BD % E6 % 95% B0 & ie = UTF-8
------ Solution --------------------
Reference:
Quote: reference:
Http://www.baidu.com? Wd = Smarty % E6 % A8 % A1 % E6 % 9D % BF % E5 % 87% BD % E6 % 95% B0 & ie = UTF-8
I still don't quite understand it. can you give me more details? For example, how do I modify the following code to a Smarty template function?
Function sgmdate ($ dateformat, $ format = 0) {$ result = ''; if ($ format) {$ time = time ()-$ dateformat; if ($ time> 24*3600) {$ result = date ('Y-m-D', $ dateformat);} elseif ($ time> 3600) {$ result = intval ($ time/3600 ). 'hour before ';} elseif ($ time> 60) {$ result = intval ($ time/60 ). 'minute ago ';} elseif ($ time> 0) {$ result = $ time. 'seconds ago ';} else {$ result =' ';} else {$ result = date ('Y-m-D', $ dateformat );} return $ result ;}
The template source code is as follows:
Smarty template engine
Then you can find it in your php file.
$ Tpl-> assign ("home", $ home );
Before that, add the following sentence and you will be OK:
$ Home ['regtime'] = sgmdate ($ home ['regtime'], 1 );