The tip of each network can be calculated on the client browser using the following formulas, rather than using the api tip endpoint. and trying to sync up. Calculations are based off of the current unix epoch seconds in UTC.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC
let t = current unix epoch second in UTC (needs to be in seconds, not milliseconds) Can validate that you're getting the correct value from this site here: https://www.epochconverter.com/
Testnet:
Global Slot (g) = t - 1594369216
Epoch Slot (e) = (g - 1598400) mod 432000
Epoch = ((g - e - 1598400) / 432000) + 74
Preview:
Global Slot (g) = t - 1666656000
Epoch Slot (e) = g mod 86400
Epoch = (g - e) / 86400
Preprod:
Global Slot (g) = t - 1655683200
Epoch Slot (e) = (g - 86400) mod 432000
Epoch = ((g - e - 86400) / 432000) + 4
Mainnet:
Global Slot (g) = t - 1591566291
Epoch Slot (e) = (g - 4492800) mod 432000
Epoch = ((g - e - 4492800) / 432000) + 208
The tip of each network can be calculated on the client browser using the following formulas, rather than using the api tip endpoint. and trying to sync up. Calculations are based off of the current unix epoch seconds in UTC.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC
let t = current unix epoch second in UTC (needs to be in seconds, not milliseconds) Can validate that you're getting the correct value from this site here: https://www.epochconverter.com/
Testnet:
Global Slot (g) = t - 1594369216
Epoch Slot (e) = (g - 1598400) mod 432000
Epoch = ((g - e - 1598400) / 432000) + 74
Preview:
Global Slot (g) = t - 1666656000
Epoch Slot (e) = g mod 86400
Epoch = (g - e) / 86400
Preprod:
Global Slot (g) = t - 1655683200
Epoch Slot (e) = (g - 86400) mod 432000
Epoch = ((g - e - 86400) / 432000) + 4
Mainnet:
Global Slot (g) = t - 1591566291
Epoch Slot (e) = (g - 4492800) mod 432000
Epoch = ((g - e - 4492800) / 432000) + 208