Hello experts,
I am stuck with an query. Actually i want to fetch current date records from my database and the below code probably fetches all my current date records. But it fetches in d/m/y (26/01/14) format but i need in dd/mm/yyyy (26/01/2014) .
Below is the code which gives output as d/m/y format:
[code=php]
<?php
ini_set( “display_errors”, 0);
$con=mysqli_connect(“localhost”,”root”,””,”test”);
// Check connection
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
$today = date(‘d-m-y’);
$result = mysqli_query($con,”SELECT * FROM Persons WHERE DATE(startdate) = ‘$today'”);
echo “<table border=’1’>
<tr>
<th>id</th>
<th>name</th>
<th>Startdate</th>
<th>Details</th>
</tr>”;
while($row = mysqli_fetch_array($result))
{
echo “<tr>”;
echo “<td>” . $row[‘id’] . “</td>”;
echo “<td>” . $row[‘name’] . “</td>”;
echo “<td>” . $row[‘startdate’] . “</td>”;
echo “<td>” . $row[‘details’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;
mysqli_close($con);
?>
I tried with the above code and also tried to change the date format i.e :
$today = date(‘d-m-y’);
to $today = date(‘dd-mm-yyyy’);
I am not understanding what i am missing. Just need some help in this. Any help is appreciated.