Hi guys. i have an event page that displays events from database. in my database I have a column with datetime format. is there a way to only get the date or time separate from each other in a select to be displayed?
php:
<?php
require "connection.php";
$sessid = $_SESSION['sess_user_id'];
$check = $dbh->prepare("SELECT * FROM event WHERE euser_id = $sessid ORDER BY start_event ASC ");
$check->execute(array('euser_id'));
if($check->rowCount() > 0)
{
$check->setFetchMode(PDO::FETCH_ASSOC);
while($row = $check->fetch())
{
$dstart = $row['start_event'];
echo
"<tr>
<td>$dstart</td>
</tr>";
}
}
?>
so right now in the database column start_event its like : 2014-08-09 13:30:00:00000 and
what i want to be displayed in the event page is the date only: 2014-08-09.
i found this link on stackoverflow but it shows the function being used in the where clause and well thats not what i want.
i tried the DATE function like this:
while($row = $check->fetch())
{
$dstart = $row['start_event'];
$dstarting = DATE($dstart);
echo
"<tr>
<td>$dstarting</td>
</tr>";
}
but i guess im not doing it right because it still shows 2014-08-09 13:30 in the event page. and also if its possible to change the format of the date when displayed; instead of yyyy-mm-dd it shows dd-mm-yyyy.
TIA!