2FA apps are time-based, so in order for your 2FA code to work, your phone's time must be in-sync with the official time. This means, you can disconnect your phone from the internet and it will still successfully generate correct 2FA codes so long as its time is correct.
Please be aware that manual time settings and offline devices eventually slip out of sync. Should your phone's time get out of sync, or if you change time zones, you can easily fix this by changing the time settings on your phone from "Manual" to "Automatic".
|On iPhone||On Android|
Depending on the manufacturer of the phone, Android instructions may vary slightly.
You can also try using the Time Sync feature if you use Google Authenticator for Android as an alternative.