php语法计算两个日期相差的天数(当前星座)

2024年06月06日 建站教程

php如何计算两个日期相差的天数,以及当前时间的星座,下面web建站小编给大家详细介绍一下代码!

计算两个日期相差的天数

function diffBetweenTwoDays ($day1, $day2)
{
  $second1 = strtotime($day1);
  $second2 = strtotime($day2);
     
  if ($second1 < $second2) {
    $tmp = $second2;
    $second2 = $second1;
    $second1 = $tmp;
  }
  return ($second1 - $second2) / 86400;
}
$day1 = "2022-10-27";
$day2 = "2022-11-01";
$diff = diffBetweenTwoDays($day1, $day2);

echo $diff."\n";

计算今天的星座

$time = new Time();
echo $time->magicInfo('XZ');

本文链接:http://so.lmcjl.com/news/6040/

展开阅读全文
相关内容