如果我有几个字符串$startDate
and $endDate
被设置为(例如)"2011/07/01"
and "2011/07/17"
(指2011年7月1日和2011年7月17日)。如何计算从开始日期到结束日期的天数?在给出的示例中,该时间为 17 天。
这是原始方法
$startTimeStamp = strtotime("2011/07/01");
$endTimeStamp = strtotime("2011/07/17");
$timeDiff = abs($endTimeStamp - $startTimeStamp);
$numberDays = $timeDiff/86400; // 86400 seconds in one day
// and you might want to convert to integer
$numberDays = intval($numberDays);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)