尝试使用PHP获取两个日期之间的差异 [英] Trying to get the difference between 2 dates in days using PHP
问题描述
我试图通过计算记录中两个日期之间的差异来获得记录的年龄。到目前为止的所有努力都失败了我是新手,所以任何帮助或建议都将不胜感激。
我刚开始使用PHP,所以请耐心等待。我试图这样做了两个星期,但没有约会。我正在做一个报告,通过尝试从关闭日期减去创建日期来给我记录的年龄。我拥有的众多代码之一如下:
I am trying to get the age of a record by calculating the difference between two dates in the record. All efforts to date have failed. I am new at this so any help or advice would be greatly appreciated.
I am just starting in PHP so please bear with me. I have tried to do thus myself for 2 weeks but have failed to date. I am doing a report that will give me the age of the record by trying to subtract the created date from the closed date. One of the many codes I have is as follows:
$sql = 'SELECT * FROM table WHERE status="Closed" ';
foreach ($pdo->query($sql) as $row) {
echo '<tr>';
echo '<td>'. $row['id'] . '</td>';
echo '<td>'. $row['status'] . '</td>';
echo '<td>' (date_diff(. $row['created'] , $row['now'] .))'</td>';
echo '</tr>';
}
Database::disconnect();
?>
date_diff无法正常工作,虽然我尝试了很多变化,但我似乎无法得到它工作。我将非常感谢您提供正确解决方案的任何帮助或建议。
我的尝试:
我所知道的一切都在搜索互联网。我尝试了很多解决方案,但还没有成功
The date_diff is not working and although I have tried numerous variations I just cannot seem to get it to work. Any help or suggestions where I might find the correct solution would be greatly appreciated.
What I have tried:
Everything I know form searching the Internet. I have attempted many solutions but have not yet succeeded
推荐答案
sql ='SELECT * FROM table WHERE status =Closed';
foreach(
sql = 'SELECT * FROM table WHERE status="Closed" '; foreach (
pdo-> query(
pdo->query(
sql)as
这篇关于尝试使用PHP获取两个日期之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!