Use DateInterval in PHP 5.x to convert DateTime objects into friendly time displays
/** * Friendly date and time * * @param DateTime $datetime date and time - * @param int $size accurate to digits
- * @throws InvalidArgumentException
- * @return string
- */
- function friendly_date($datetime, $size=1)
- {
-
- ‑‑ ‑‑‑‑‑‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ $interval = $now->diff($ datetime);
- ,,,,,, $interval- >s,
- );
- $intervalFormat = array('year', 'month', 'day', 'hour', 'minute', 'second');
- foreach($intervalData as $index= & gt; $ value) {
- if ($ value) {
- $ intervaldata [$ Index] = $ value. $ IntervalFormat [$ Index]; dex]); n Unset ($ intervalFormat[$index]);
- intervalFormat[$index]);
-
-
-
-
-
-
-
-
-
|