Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Age Calculator
SUBMITTED BY:
PaperBoy
DATE:
May 14, 2016, 4:27 p.m.
FORMAT:
PHP
SIZE:
427 Bytes
Raw
Download
Tweet
HITS:
507
Go to comments
Report
<?php
function
birthday
(
$birthday
){
$age
=
strtotime
(
$birthday
);
if
(
$age
===
false
){
return
false
;
}
list
(
$y1
,
$m1
,
$d1
)
=
explode
(
"-"
,
date
(
"Y-m-d"
,
$age
));
$now
=
strtotime
(
"now"
);
list
(
$y2
,
$m2
,
$d2
)
=
explode
(
"-"
,
date
(
"Y-m-d"
,
$now
));
$age
=
$y2
-
$y1
;
if
((
int
)(
$m2
.
$d2
)
<
(
int
)(
$m1
.
$d1
))
$age
-=
1
;
return
$age
;
}
echo
birthday
(
'1986-07-22'
);
?>
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus