a short tutorial ...
... you need a additional_image_field (try forum search) for image_date_lastview ...
... in detail.php you need a query to put the current date in this image field ( e.g. like the image counter in details.php ) ...
... and then you can use a similar code for lastview images as for new images ... like in index.php / home.html (use a copy)...
... but in index.php you must change to ...
ORDER BY i.image_date_lastview ...
... and instead of all
$new_images in your new code of index.php you must use ...
$lastview_images ...
... in home.html you can use then
{lastview_images} ...