我有两个字符串如下。
如何在PHP中区分它们?
我尝试过以下代码
<?php echo date_diff(date_create($experience[$i]->StartWork),date_create($experience[$i]->EndWork))->format("%a days"); ?>
答案 0 :(得分:1)
你可以简单地这样做
<?php
$date1 = "may 1994";
$date2 = "august 1997";
$diff = strtotime($date2)-strtotime($date1);
$days = $diff / (60*60*24*1);
echo "days :". $days;
?>
答案 1 :(得分:0)
$date1 = new DateTime("may 1994"); //$experience[$i]->StartWork
$date2 = new DateTime("august 1997"); //$experience[$i]->EndWork
$interval = $date1->diff($date2);
echo "days diff = " . $interval->days ;