I do not know that there is a "standard" way.
There may be existing services that can do this, and there may be databases that you can purchase or get for free that have usable data, but depending on your definition, it can be easy to calculate.
Think about it: your question can be interpreted as the shortest distance between two points (cheating using a point in the city lying in this zip code), or it can be interpreted as the distance between the edge of the two borders of the zip code. The first calculation is quite simple, but not 100% accurate. The second is not a simple problem. Finding the shortest distance is one of the subtasks, and finding the nearest points on the edge of irregular borders is another subtask (or searching for the nearest cities / known coordinates of the person calling this function).
So, without any information about the real problem that you are trying to solve, I can only assume that you do not care how accurate your data is. In this case, I propose to obtain a database of the coordinates of the cities in which they lie, and use standard subtractions / square root to determine the distance (Pythagorean theorem).
If you donβt care how accurate your data is, I suggest you do a research to find an existing database or service that has more accurate information that was previously calculated for you or processed by you.
source share