I can't get this date with strtotime function to work properly. I need to convert the date to display to "d/m/Y". I'm getting the date off the database correctly but it does not convert to my new date format, instead it just echoes everything with the date inside the $row[saleDate].
Here's the code:
echo "<tr><td class='contentTd'> $row[saleNumber] </td>
<td class='contentTd'> $row[saleValue] </td>
<td class='contentTd'> $row[paymentMethod] </td>
<td class='contentTd'> $row[sellerName] </td>
<td class='contentTd'> date('d/m/Y', strtotime($row[saleDate]));
</td></tr>";
Could you help me out please?
Use concatenation to show the date..
echo "<tr><td class='contentTd'> $row[saleNumber] </td>
<td class='contentTd'> $row[saleValue] </td>
<td class='contentTd'> $row[paymentMethod] </td>
<td class='contentTd'> $row[sellerName] </td>
<td class='contentTd'>".' date('d/m/Y', strtotime($row[saleDate]);'.
"</td></tr>";
我认为您忘记了date()函数或strtotime()函数
I've found the error: Missing quotes inside the strtotime function.
echo "<tr><td class='contentTd'> $row[saleNumber] </td>
<td class='contentTd'> $row[saleValue] </td>
<td class='contentTd'> $row[paymentMethod] </td>
<td class='contentTd'> $row[sellerName] </td>
<td class='contentTd'>" . date('d/m/Y', strtotime("$row[saleDate]")) . "</td></tr>";
Now it's working fine!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.