Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Zip codes to Time zone for US

Tags:

python

I have US ZIP codes, now I need to get their respective time zones. Could you please help me with any mapping file or Python or R code for this.

like image 478
Manoj Avatar asked Sep 12 '25 09:09

Manoj


1 Answers

Use "Ziptz" library for this. Usage:

z = Ziptz.new
z.time_zone_name('zipcode')

Result:

Pacific

Get all the zip codes in a time zone

 z.zips('American Samoa') #=> ["96799", "96941", "96942", "96943", "96944"]

Supported Timezone

  • "Atlantic" UTC -04:00
  • "Eastern" UTC -05:00
  • "Central" UTC -06:00
  • "Mountain" UTC -07:00
  • "Pacific" UTC -08:00
  • "Alaska" UTC -09:00
  • "Hawaii-Aleutian Islands" UTC -10:00
  • "American Samoa" UTC -11:00
  • "Marshall Islands" UTC +12:00
  • "Guam" UTC +10:00
  • "Palau" UTC +09:00
  • "Micronesia" UTC +11:00

For more: ziptz

For Python

Install

pip install pyzipcode

Usage:

from pyzipcode import ZipCodeDatabase
zcdb = ZipCodeDatabase()
zipcode = zcdb[54115]

To get City Name:

zipcode.city

Result

u'De Pere'

To Get Timezone

zipcode.timezone

Result:

-6

For more: pyzipcode

like image 68
Jishnunand P K Avatar answered Sep 14 '25 01:09

Jishnunand P K