Convert timestamp from SQL in PHP
Posted: 26 Sep 2018, 10:58
Well some new problem. I have a simple code to convert timestamp so it`s able to read.
But now I would like to have the same result into this SQL document.
I want to add '. $row['timestamp']. ' into this document
but when I enter it I can`t read it. example: 1537899452
Code: Select all
timestamp 1537939165
<?php echo date(DATE_RFC822, 1537939165); ?>
result: Wed, 26 Sep 18 07:19:25 +0200
Code: Select all
<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'system_chat', '123456', 'system_chat');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT * FROM `blab_lines` ORDER BY `line_id` DESC LIMIT 10";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
while($row = $result->fetch_assoc()) {
echo '<br><div class="venster">
'. $row['from_name']. '
<br>
'. $row['line_txt']. '
</div> ' ;
}
}
else {
echo 'No-one added yet a @1';
}
$conn->close();
?>
but when I enter it I can`t read it. example: 1537899452