How does PHP calculate age, domain name age? Known yyyy-mm-dd. To find the age of the domain.
How to calculate the age of a domain name it's been a long time since I wrote a function, but it's wrong, because some years are a leap year.
Time input must unit
function Mathage ($ymd 2) {
$ymd 1 = "2012-2-27";
@list ($y 1, $m 1, $d 1) = Explode ("-", Date ("Y-m-d", Strtotime ($ymd 1)));
@list ($y 2, $m 2, $d 2) = Explode ("-", Date ("Y-m-d", Strtotime ($ymd 2)));
$arr = Array (
"Year" = Round ($y 1-$y 2),
"Month" = Round ($m 1-$m 2),
"Day" = Round ($d 1-$d 2),
);
$arr ["Day"] = Round ($d 1-$d 2);
while ($arr ["Day"] < 0) {
$arr ["Day"] + = 30;
$arr ["Month"]-= 1;
}
while ($arr ["Month"] < 0) {
$arr ["Month"] + = 12;
$arr ["Year"]-= 1;
}
$txt = ";
foreach ($arr as $k = $v)
{
if (! $v) continue;
$txt. = $v. $k;
}
echo "$ymd 1-$ymd 2 = $txt \ n";
return $txt;
}
$DATEARR = Array (
"2011-12-28",
"2011-12-29",
"2011-12-27",
"2010-12-28",
"2010-12-29",
"2010-12-27",
"2011-10-1",
"2010-5-1",
"2010-2-28",
"1995-1-1",
"1995-12-31",
);
foreach ($dateArr as $date)
{
Mathage ($date);
}
?>
The above output test content is:
How to calculate the difference between the two dates? Consider leap year February.
------Solution--------------------
Well, I am not very clear, but deliberately come to the top of the landlord