0

I have dates and times setup in the database separately. start is in YYYY-MM-DD format and time is in HH:MM:SS format. I'm trying to modify the start date to show the date in a readable format.

I've tried to output using php and I get "Wednesday, Dec 31 1969" which is nothing like I want. (right format, but the date isn't anything I have in the database).

And i've used DATE_FORMAT('start','%W, %M %d %Y') AS startbut my select function has it order by start and it doesn't give me the right order and values specified. but format is right.

my php code is

$sql = "SELECT `title`, `time`, `start`, `showFeed` FROM calender WHERE length('column') > '0' and showFeed=1 ORDER BY `start` ASC LIMIT 0,4";

/*  DATE_FORMAT(`start`,'%W, %M %d %Y') AS start   */

    $result = $dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);

echo "<div class=\"eventfeed\">";
echo "<ul>";

foreach ($result as $row){
$dt = $row['start'];
$ts = $row['time'];

$date = strtotime( $dateout );
$dateout = date( 'l, M j Y', $phpdate );



    echo "<dl>";
    echo "<dt>". $row['title']. "</dt>";
    echo "<dd>".  $dateout;
    echo "</dl>";

}

echo "</ul>";
echo "</div>";

$dbh = null;

I don't know what possibly I'm doing wrong. I've done this before and for some reason formatting dates isn't working this time around.

1 Answer 1

1

Try this:

<?php
$dt = $row['start'] . ' ' . $row['time'];
echo date('l, M j Y', strtotime($dt));

I'm not sure if it was just a typo, or if it's your code, but - you're referencing $dateout before it's set, and $phpdate, which is never set.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.