How php outputs the time format before a specified time
This article mainly introduces php how to output the specified time before the time format, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
The specific analysis is as follows:
For example, if you need to output in php 3 days ago, 20 minutes ago, you can refer to the following code
Function ago ($time) {$time = strtotime ($time); $delta = time ()-$time; if ($delta < 60) {return 'less than a minute ago.';} else if ($delta < 120) {return' about a minute ago.';} else if ($delta < (45 * 60)) {return floor ($delta / 60). ' Minutes ago.';} else if ($delta < (90 * 60)) {return 'about an hour ago.';} else if ($delta < (24 * 60 * 60)) {return' about'. Floor ($delta / 3600). ' Hour (s) ago.';} else if ($delta < (48 * 60 * 60)) {return'1 day ago.';} else {return floor ($delta / 86400). ' Days ago.';}} Thank you for reading this article carefully. I hope the article "how to output the time format before the specified time" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!