Getting a year from a MySQL timestamp

To filter by a year when the date has been saved as a timestamp, do this. pub_date if the stored record.

$query = "SELECT FROM_UNIXTIME(pub_date, '%Y') as year FROM ".$table ." WHERE parent='177' AND deleted='0' AND FROM_UNIXTIME(pub_date, '%Y')='2010' AND published='1' ORDER BY pagetitle";

About Keiron

Web Developer based in the UK. Click here if you want to work with me