There's a difference of opinion on this matter some say you start fasting (Ramadan) with those you witnessed its beginning and you stop fasting with those you witnessed its ending based on:
the Prophet said: "The fast is the day the people fast, the breaking of the fast is the day the people break their fast, and the sacrifice is the day the people sacrifice." (Jami' at-Tirmidhi)
“When you see the new crescent then fast, and when you see it then stop fasting. If it is cloudy then fast thirty days.” (Sahih Muslim)
Whenever you sight the new moon (of the month of Ramadan) observe fast. and when you sight it (the new moon of Shawwal) break it, and if the sky is cloudy for you, then observe fast for thirty days. (Sahih Muslim)
Note that even if the translations here quote "thirty days" in some narrations the correct wording is rather "full" or "complete".
The first hadith seems to say that you should fast with the community and break it with the community.
Among the scholars who said that one may need to fast in such a case thirty one days you may find ibn Taymiyyah and islamqa #71203 presents this as the view of the majority. This site (in Arabic) on the international time line and its implication on worship says only the shafi'is differ from this and say one must break his fast in secrete as the month is complete.
Other sources say that the shafi'i say otherwise and abu Hanifa considered this as the ruling for a person who saw the hilal alone (one day earlier than his community, and none believed him) he should keep on fasting until the community breaks the fast. Some others say one should intend to break fast but fast with the jama'a
Note that in the opposite case: fasting 28 days instead of 29 or 30 you need to make up one day to have your month complete. Because a month by default is at least 29 days based on ahadith such as this and this.
So to conclude: it seems that the most correct procedure is to fast your 31st day even if a month can't have more than 30 days. But humans make mistakes (either those you started fasting with or those who where not able to sight th new hilal) and hopefully this addional day will count as a nafl fast for you.