Reputation: 41
Im trying to convert the timestamp into a date:
echo '<td>' . strtotime(mysql_result($result,$i,"datum_overboeking")) = date('d-m-Y'). '</td>';
This gives me an error: Fatal error: Can't use function return value in write context
I want the strtotime output do an input in the date ('d-m-y') so it will output the given date format.
update:
Perfect it works, thanks !
But how can you find this way of correct syntax construction because Im always struggling how to correctly build up a syntax like this ?
Upvotes: 1
Views: 336
Reputation: 171
Use the second parameter of the date function.
date('d-m-Y', strtotime(mysql_result($result,$i,"datum_overboeking")));
look at the date function
http://www.php.net/manual/en/function.date.php
Upvotes: 2
Reputation: 163
Maybe you can use something like this:
<?php
$overboeking = mysql_result($result,$i,"datum_overboeking");
try {
$date = new DateTime($overboeking);
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
echo '<td>'.$date->format('d-m-Y').'</td>';
?>
Upvotes: 0