5

There does not seem to be a direct way to extract the time zone for a ZIP code. Currently, I am first mapping the ZIP code to the states, and then getting the time zones for those states.

"94402" //
Entity["ZIPCode", #] & //
EntityValue[#, "USStates"] & //
Map[EntityValue[#, "TimeZones"] &]

But this is obviously wrong. This will return multiple time zones even when a given ZIP code lies within a single time zone.

Is there a better way of getting the time zone for a ZIP code through Entity?

Shredderroy
  • 5,249
  • 17
  • 26

2 Answers2

11
TimeZoneOffset[Entity["ZIPCode", "94402"]]

-8.

kglr
  • 394,356
  • 18
  • 477
  • 896
6

This will do what you want:

TimeZoneOffset[GeoPosition[Entity["ZIPCode", "94402"]["Coordinates"]]]

-8

Each zip code entity has coordinates associated with them, and TimeZoneOffset can take a GeoPosition and return the timezone offset from GMT.

It should be noted that kglr's answer is the shorter (and more graceful) form of this answer - they are doing the same thing under the hood.

Carl Lange
  • 13,065
  • 1
  • 36
  • 70