Php timeline function, which is a common time processing function in php just one minute ago, one hour ago, or one day ago: time (): returns the current Unix timestamp ?. Date (): format a local time/date. Getdate (): Get date/time information. Mktime (): normal date to timestamp. Mktime (php timeline function, just one minute ago, one hour ago, one day ago
Common php time processing functions:
Time (): returns the current Unix timestamp ?.
Date (): format a local time/date.
Getdate (): Get date/time information.
Mktime (): normal date to timestamp. Mktime (0, 0, 0, 9, 18,201 1)
The following is a timeline processing function.
/*** Time formatting */static function formatDate ($ time) {$ rtime = date ("m-d H: I", $ time ); $ htime = date ("H: I", $ time); $ time = time ()-$ time; if ($ time <60) {$ str = 'hangzhou';} elseif ($ time <60*60) {$ min = floor ($ time/60); $ str = $ min. 'minute ago ';} elseif ($ time <60*60*24) {$ h = floor ($ time/(60*60); $ str = $ h. 'hour ago '. $ htime;} elseif ($ time <60*60*24*3) {$ d = floor ($ time/(60*60*24 )); if ($ d = 1) $ str = 'Yesterday '. $ rtime; else $ str = 'day before yesterday '. $ rtime;} else {$ str = $ rtime;} return $ str ;}
?