时间:2021-07-01 10:21:17 帮助过:30人阅读
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 . "岁";
}
if ($bm == 0&&$bd == 0){
$rday .="生日";
}else{
if ($bm == 0){
$rday.="零".$bd."天";
}elseif ($bd == 0){
$rday.=$bm."个月整";
}else{
$rday.=$bm."个月".$bd."天";
}
}
return $rday;
}
用的时候直接
代码如下:
就可以了
空下来再完善以下,再写一个js的版本。