i have this code and i have problem in Datetime() if i get timestamp in my database he working fine but after go to another page and come back to this page code every time the counter come back to 1 seconde and starts counting again
but when use the timestamp directly like this counter work fine
$then = new DateTime('2016-03-18 23:47:41' , new DateTimeZone('Europe/London'));
this code when get timestamp in database e_time column give him timestamp type
<?php
$stmt = $DB_con->prepare("SELECT * FROM `post` WHERE `e_stauts`=1 AND `lockin`=1 ORDER BY `id` DESC");
$stmt->execute();
}
foreach ($stmt->fetchAll() as $row) {
echo"".$row['e_title']." </br>";
$then = new DateTime(''.$row['e_time'].'' , new DateTimeZone('Europe/London'));
$now = new DateTime();
$delta = $now->diff($then);
$quantities = array(
'year' => $delta->y,
'month' => $delta->m,
'day' => $delta->d,
'hour' => $delta->h,
'minute' => $delta->i,
'second' => $delta->s);
if($quantities['day'] != 0){
echo "".$quantities['day']." Day ".'</br>';
}elseif($quantities['day'] == 0 & $quantities['hour'] > 0){
echo "".$quantities['hour']." Hour ".'</br>';
}elseif($quantities['hour'] == 0 & $quantities['minute'] > 0){
echo "".$quantities['minute']." Minute ".'</br>';
}elseif($quantities['minute'] == 0 & $quantities['second'] > 0){
echo "".$quantities['second']." Seconde ".'</br>';
}
}