Subtraia alguma data e hora da data e hora atuais para encontrar a idade no PHP
Suponha que eu tenho um ingresso$create_time = "2016-08-02 12:35:04"
. Eu quero subtrair o$create_time
a partir da data e hora atuais, como$current_time="2016-08-02 16:16:02"
para encontrar a idade no formato3hr 41min
.
<?php
$sql = "SELECT count(*) as total, create_time FROM article where ticket_id='$ticket_id'";
$otrs_db = $this->load->database('otrs',true);
$result = $otrs_db->query($sql);
foreach($result->result() as $row)
{?>
<div class="pull-left">
<h4><b><?php echo $row->total ;?> Article(s)</b></h4>
</div>
<div class="pull-right">
<h4>Age: <?php echo date("Y-m-d H:i", strtotime("-$row->create_time",strtotime($thestime))) ?>Created: <?php echo $row->create_time; ?></h4>
</div>
<?php
}
?>
Eu sei que meu código de subtração de data está errado. Como posso fazer certo?