Adeola Web
Adeola Web

Reputation: 11

how i can include time from database to "Days ago code below"

I have a code for days interval

<?php 
    $datetime1 = new DateTime(); // Today's Date/Time  
   $datetime2 = new DateTime('2012-07-17 15:30:17'); 
   $interval = $datetime1->diff($datetime2); 
   echo $interval->format('%D days %H hours %I minutes ago'); 
?>

How can I include time from database example

<?php echo htmlentities($row['date']); ?>

Upvotes: 0

Views: 52

Answers (1)

Moshe
Moshe

Reputation: 2684

I know you're using PHP, but if you want this on the front end you could consider moment.js: https://momentjs.com/ it handles human-like date outputs.''

Edit: after further searching, this is exactly what you're looking for momentPHP: https://github.com/fightbulc/moment.php

Upvotes: 1

Related Questions