Any person entering Thailand will have an arrival stamp on his/her passport upon entering Thailand.
At the port of entry the officer will calculate the duration of your period of stay depending on the type of visa and write within the arrival stamp frame the date until which you are allowed to stay.
Therefore the answer to this question is quite obvious. At the time of your departure or at the time of any control (by the immigration officer or a police officer at a check point) it suffices to look at your latest arrival stamp to know whether you overstayed or not.
It is also good to know that the Thai immigration records are computerized. Any arrival or departures are recorded into the immigration computers and all the information are centralized at the Central Immigration Bureau and constantly updated.
Please know that you never attempt to alter in anyway your arrival stamp. If the officer of immigration miscalculated the duration of your period of stay or if the writing is unreadable, do not attempt to correct it by yourself. By doing so you would face serious criminal charges and end up in jail. While both are criminal activities the fact is that Thai authorities react always more strongly and punished more severely attempt that are made to alter or falsify Thai official documents than to attempt that are made to falsify or forge foreign documents.
Also, an overstay can be cleared by paying a fine at the immigration office or at the immigration point of departure. Even though we know that an overstay can be cleared pretty easily, it is still advisable not to stay beyond the time of your maximum departure since it is still considered illegal. The consequence that you may face is to be arrested or controlled or you may find yourself detained and eventually deported.