OS X: find hours in use
Do you mean that you want to know the length of time of the current login session, or the total use for the machine since it left the factory?

The latter is not possible because the logs that store that sort of information rotate. The former is sort of possible, but will take you checking the logs frequently. For one, the last command will show recent login sessions.

I don't think any of those options will strip out sleep time, so that would take a lot more effort where you'd have to write a log parser that looked for sleep/wake events and took that time out of the appropriate login session.

It's not something there is a simple solution for.

If you want to keep track of logins and logout you would be better off writing a loginhook and logouthook to log to your own file.