Download SmartReporter and copy its folder to the Applications folder. Then run this in the Terminal:
Code:
/Applications/SMARTReporter/SMARTReporter.app/Contents/Resources/smartctl /dev/disk0 -a
The Terminal will then print out lots of stuff. Under the "Vendor Specific SMART Attributes with Thresholds:" heading look for "Power_On_Hours".
In the Raw_Value column for this attribute will be how long the hard drive has been on in hours. If the iMac has the original hard drive, that'll be how long the iMac has been on.