I'm VERY new to PHP and I have been looking into this for a while, and tried a few solutions on here which haven't worked.
I have been making a website for a class at university, a festival website, and I have been trying to display a specific user inputted date (via CMS system) rather than a hardcoded date (which is all I can seem to find solutions for online).
Here is an example of my code:
$query = "SELECT * FROM gatherings";
$select_all_events_query = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_all_events_query)) {
$gather_id = $row['gather_id'];
$gather_name = $row['gather_name'];
$gather_date = $row['gather_date'];
$gather_img = $row['gather_img'];
$gather_content = substr($row['gather_content'], 0, 150);
$gather_supporting = $row['gather_supporting'];
$gather_tags = $row['gather_tags'];
$gather_status = $row['gather_status'];
if($gather_status == 'Published') {
?>
<div class="col-sm-6">
<div class="eventcard-left card">
<div class="card-body card-body-align text-center">
<h1 class="card-title"><?php echo $gather_name; ?></h1>
<p class="card-text"><?php echo $gather_content; ?></p>
<h1 class="card-title"><?php echo date_format($gather_date,"d/m/Y"); echo "<br>"?></h1>
<a class="btn btn-outline" href="event.php?p_id=<?php echo $gather_id; ?>" class="btn btn-primary">View Event</a>
</div>
</div>
</div>
}
No matter what I do it always displays as YYYY-MM-DD, I know it's probably a really simple solution but I've tried so much and can't get it to change. When I create my event I have tried changing this too, no luck. If there's anything else you need to help me out I can provide.
if(isset($_POST['create_event'])) {
$gather_name = $_POST['gather_name'];
$gather_date = date('d-m-Y');
}
Also, on the subject of dates and times, I am trying to display times as 00:00, but only returning 00:00:00, hopefully the two solutions are similar.