2

from this use example:

echo time_elapsed_string('2013-05-01 00:22:35', true);

from this Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...

it must write exactly the date '2013-05-01 00:22:35'

now, i want to take date from this data in red box: enter image description here which i succeed if i write it like this:

<h4>di posisi sekarang:<br> <?php echo $row["tanggal"];  ?></h4><br>

but when i used it like this:

echo time_elapsed_string('<?php echo $row["tanggal"];  ?>', true);

it doesn't work, how do i get the data right?

borneo
  • 97
  • 9

1 Answers1

3

You are trying to write PHP inside a PHP string. Just remove PHP tags and echo:

echo time_elapsed_string($row["tanggal"], true);

In your context:

<h4>di posisi sekarang:<br> 
    <?php echo time_elapsed_string($row["tanggal"], true);  ?>
</h4><br>
Syscall
  • 19,327
  • 10
  • 37
  • 52