0

I have table with row id, name, created_at and I want to output the created_at row as timestamp time ago in php

1 Answers1

0

replace time() method with created_at

$date = date("Y-m-d H:i:s", time());

Is this will help you ? Convert time in HH:MM:SS format to seconds only?

... converted to seconds

// example date from db
$created_at = "22-05-15 00:49:59";
$created    = strtotime($created_at);
$current    = strtotime("now");
$diff       = $current - $created;
echo "Diff: " . $diff . " \n";
obeid salem
  • 129
  • 2
  • 13