我一直在尝试根据数据库中存储的天数获得包的年数和月数或仅数月(如果少于 365 天)的有效性。
我所做的是以天为单位存储包裹的有效计数。例如。1680 或 365。
我需要分别显示 5 年和 1 年 x 月。
我一直将 1 个月计算为 28 天。
有人能帮我吗?我试过的:
if (days_count > 336) {
year = count/28*12; // here i will get the year.how will i get Month
} else {
// calculate for month and days
month = count/28;
}
$count = 1710;
$totalMonth = (int) ($count/28) ; // 5
echo $year = (int) ($totalMonth/12);// 1
echo $month = $totalMonth % 12;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句