'How to output sql date row to time elapsed
I have table with row id, name, created_at and I want to output the created_at row as timestamp time ago in php
Solution 1:[1]
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";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
