The main function is to show how old Beibei is now based on Beibei's date of birth, and to display Beibei's growth in real time.
Subtract the date of birth from the current time, but can display the age, months, and days.
There is something wrong with the day algorithm, as it does not take into account the big and small months and February.
Copy code The code is as follows:
function getDays() {
putenv("TZ=Asia/Chongqing") ;
$by = 2006;
$bm = 7;
$bd = 7;
$rday="";
$today = getdate();
$by = $today[year] - $by;
$bm = $today[mon] - $bm;
$bd = $today[mday] - $bd;
if ($bd < ; 0) {
$bd = 30 + $bd;
$bm--;
}
if ($bm < 0) {
$bm = 12 + $bm;
$by--;
}
#print $by."-".$bm."-".$bd;
if ($by > 0) {
$ rday = $by . "year";
}
if ($bm == 0&&$bd == 0){
$rday .="birthday";
}else{
if ($bm == 0){
$rday.="zero".$bd."day";
}elseif ($bd == 0){
$rday.=$bm. "month";
}else{
$rday.=$bm."month".$bd."day";
}
}
return $rday;
}
When using it, just copy the code
The code is as follows:
< ?php echo getDays();?>
That’s it.
Leave it blank and then improve the following and write a js version.
http://www.bkjia.com/PHPjc/325998.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325998.htmlTechArticleThe main function is to show how old Beibei is now based on Beibei's date of birth, and to display Beibei's growth in real time. Subtract the date of birth from the current time, but you can show how old you are...