The following is a datetime date time conversion adult \ ', \ ' months \ ', \ ' days \ ', \ ' hours \ ', \ ' sub-species \ ', \ ' s \ ' to show that the need for friends can refer to.
The following is a datetime date time conversion to adulthood ', ' months ', ' days ', ' hours ', ' minutes ', ' seconds ' to show that a friend in need can refer to.
/**
* Friendly Date and time
*
* Date Time @param datetime $datetime
* @param int $size Precise in-place number
* @throws InvalidArgumentException
* @return String
*/
function Friendly_date ($datetime, $size =1)
{
if (Is_int ($datetime)) {
$datetime = new DateTime ($datetime);
}
if (! ( $datetime instanceof datetime)) {
throw new InvalidArgumentException (' invalid ' DateTime "Object");
}
$now = new DateTime ();
$interval = $now->diff ($datetime);
$intervalData = Array (
$interval->y, $interval->m, $interval->d,
$interval->h, $interval->i, $interval->s,
);
$intervalFormat = Array (' Year ', ' Month ', ' Day ', ' hour ', ' minute ', ' second ');
foreach ($intervalData as $index = = $value) {
if ($value) {
$intervalData [$index] = $value. $intervalFormat [$index];
} else {
Unset ($intervalData [$index]);
Unset ($intervalFormat [$index]);
}
}
Return implode (", Array_slice ($intervalData, 0, $size));
}
http://www.bkjia.com/PHPjc/631329.html www.bkjia.com true http://www.bkjia.com/PHPjc/631329.html techarticle The following is a datetime date time conversion adult \ ', \ ' months \ ', \ ' days \ ', \ ' hours \ ', \ ' sub-species \ ', \ ' s \ ' to show that the need for friends can refer to. Here is a will datet ...