I have a script that adds content in my mysql database with a date/time stamp. It's not possible to change the input date/time for me.
i want the date-time changed when i query out of my mysql database.
cell in my db: 2016-08-17 17:34:29
It needs to be: 2016-08-17 19:34:29 ( so +02:00 hour in the php page shown to visitors)
I cannot UPDATE the time in de database because other applications depend on the data in the current format.
Thanks in advance!
Website coding now:
<?PHP
//make connection
mysql_connect('localhost','user','pass');
//select db
mysql_select_db('database');
?>
<html>
<head>
<title>Title</title>
</head>
<body>
<table>
<tr>
<th>id</th>
<th>disappear_time</th>
</tr>
<?php
$query_150="
SELECT * FROM `table`
WHERE `disappear_time` > SUBDATE( CURRENT_TIMESTAMP, INTERVAL 2 HOUR)
AND `id` = 150
ORDER BY `disappear_time` DESC";
$150 = mysql_query($query_150) or die(mysql_error());
while($row_150 = mysql_fetch_assoc($query_150)){
//handle rows.
echo "<tr>";
echo "<td>".$row_150['id']."</td>";
echo "<td>".$row_150['disappear_time']."</td>";
echo "</tr>";}
?>
</table>
</body>
</html>
I fixed it! answer is:
SELECT id2, DATE_ADD(disappear_time, INTERVAL 2 HOUR) AS disappear_time FROM `table`
WHERE `disappear_time` > SUBDATE( CURRENT_TIMESTAMP, INTERVAL 2 HOUR)
AND `id` = 147
ORDER BY `disappear_time` ASC";