Check if date is empty

html, php

Solution

You should check first what is there in date field whether it contains date or its NULL. According to result you can read date .

while ($row = mysql_fetch_array($result)) {

    if (strtotime($row['date']) != '0000-00-00') {

        mydate = date('d-m-Y', strtotime($row['date']));

    } else {
        mydate = '';
    }
}

Problem

In a `while` loop how can I have a date displayed only if that date exists? E.g.: If date is `0000-00-00`, display nothing. I am currently reading the date as follows, but I am getting `01-01-1970` when `0000-00-00`: ``` date('d-m-Y', strtotime($row['date'])) ```

Original source

Related problems