smarty raj smarty raj - 4 months ago 6x
PHP Question

php code calculate 30 minutes from created datetime field in table

In my table there is a created datetime field in which data inserting like 2016-05-25 11:50:35.

Suppose my insertion time is 11:50 and current time is 12:10,so the differnce is 20 mins.
now i need to check is get this difference in one variable and check if differnce > 30 then the edit link will be invisible else visible.

below is my code..

i get extracted mins from my created datetime field from database.

$var1 = $post['ShipperRating']['created'];
$time1 = date('i', strtotime($var1));
$finaltime = $time1;
echo $finaltime;

$createdDateTime = new DateTime($post['ShipperRating']['created']);
$createdDateTime->modify('+30 minutes');

if ($createdDateTime >= new DateTime()) {
    echo '<a href="/url">Edit</a>';