With Google Analytics, you are probably tracked on your website and also outside whenever you browse a website outside yours that uses GA (which happens quite frequently). By combining a local cookie along with a Google Cookie, I think this renders possible to follow a visitor "in" and "out" a given website, thus allowing you to compute very precisely how long you stayed on the last page.
Other techniques include using a session cookie that expires after a given delay (say 1 minute) so that if you ever stand still more than one minute on a webpage without doing anything, the cookie expires and GA will know that at next refresh (because he won't find the short lasting cookie but might find a longer running cookie still alive).
It is also possible by using some statistics distribution to attribute a mean "time spent" for a user who has visited a given page as the last one on a website just by computing how long the others users passing by this page have stayed on the site. This probably give slight wrong result for small traffic website but I think this is valid as soon as the number of visitor raises.
Modern website statistics aggregators (AW-Stats, Webalizer) provide that kind of data with no JavaScript hooks.