MySql vers 4.0.20
A table "noticeboard" has three test entries.
A unix time from date("U") is stored in the field "published" of type, bigint20.
I am not able to workout how to select the year. Assuming that the value from date("U") can be treated as a unixtime value, my latest unsuccessful effort is ....
$yearslist = mysql_query("SELECT published, FROM_UNIXTIME(UNIX_TIMESTAMP(published),'%Y') AS year FROM noticeboard") or die("Cannot get list of years.<br>" . mysql_error());
$counttotal = mysql_num_rows($yearslist); echo "<div>Rows found $counttotal</div>";
while ($myrow = mysql_fetch_array($yearslist)) {
if (ISSET($myrow['published'])){$published=$myrow['published'];}
$yearpub=date("Y",$published);
if (ISSET($myrow['year'])){ $year=$myrow['year'];}
else {echo "<div>Year is not set</div>";}
echo "<div>Year $year but value was $published. Year value should be $yearpub</div>";
}
The result is
Rows found 3 Year 1969 but value was 1083923875. Year value should be 2004 Year 1969 but value was 1113300220. Year value should be 2005 Year 1969 but value was 1113351870. Year value should be 2005
Louise