if (time()-filectime($filename) > 2 * 3600) { // file older than 2 hours } else { // file younger than 2 hours }