I am glad it works for you! Just to elaborate: whole thing could be even more complicated. TOTP works on assumption, that both sides will have the same result basing on the UTC clock and shared key.
The breaking offset depends on:
- what is your TOTP configuration period (30/60 seconds or more - the bigger value, the less chance for failure),
- your typing speed (will you enter the OTP code during the period)
- and the server implementation (is it getting the code on its side before you enter the code or after or would accept the both - my guess is it should be the latter).
Not to mention, that you might be caught on the verge of periods - that is the code will change in the very moment after you will get it - e.g. if you have 60 seconds period then the code will change every minute. If you are getting the code on 11:59:59 and clicking the send button 2 seconds later then it might be rejected (depending on server-side implementation).