Date echoes out as 1969-12-31

Some of the dates (timestamp) in my database have a value of
0000-00-00 00:00:00

when I echo out the date - I see
1969-12-31 19:00

so i have the following code to display the words n/a when the date is not valid (this part works - the first line)


if ($time_added == 0) echo 'Date Added - n/a <br/>';   
if ($time_added != 0) echo 'Date Added - ' . date("Y-m-d G:i ", strtotime($row['time_added'])).'<br/>';

the second line in my code, i want it to display the actual date stored in the database - given that it is a valid date - but it does not work … hope someone can help

Should you be comparing $row[‘time_added’] instead of $time_added?
Also you can use an else statement instead of the opposing if for the second line.

Try,

echo ($row['time_added'] == '0000-00-00 00:00:00') ? 'Date Added - n/a <br/>' : 'Date Added - ' . date("Y-m-d G:i ", strtotime($row['time_added'])).'<br/>' ;

Is there any particular reason for using that date for when the date is not applicable or unknown rather than using NULL which is the value that means not applicable or unknown.