-1

I have a list of around 400 zip codes. I need to use this code's time zone in the application. For Example:- If my code zip code 35242, after googling I found the time zone for 35242 is GMT-5. Now in the application, I need to add DateTime.Now.AddHours(-5). Is there any way to do this from code or do I have to search the timezone for all zip codes and do it manually?

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
Biraz Dahal
  • 361
  • 1
  • 5
  • 20
  • 4
    *.Net* has no understanding of what a *zipcode* is. You will have to build something yourself, or you might be lucky enough to find a library (you never know your luck) – TheGeneral Oct 21 '20 at 05:37
  • 1
    It seems there is no direct way thru you can get a time zone by zip code. It can done using some third-party service OR custom table in DB with a combination of your zip code and time zone. – Mukesh Vadodariya Oct 21 '20 at 05:38
  • Note that the `[asp.net]` and `[asp.net-mvc]` tags are for .NET Framework. If you're using .NET Core you should use `[asp.net-core]` and `[asp.net-core-mvc]` instead. Anyway, in this case they aren't relevant to the question, so I've removed them. – ProgrammingLlama Oct 21 '20 at 05:39
  • [First Google result for "zip code to timezone csv"](https://aws.amazon.com/marketplace/pp/ZIP-Code-Time-Zones/prodview-4vcapflqwntdw) – ProgrammingLlama Oct 21 '20 at 05:40

1 Answers1

2

Q: Is there any way to get time zone from zip code programmatically?

A: Sure. There are lots of databases, programming libraries and web services available. Some paid, some free; some "static" (e.g. a .csv download), others dynamic (e.g. a REST API).

SUGGESTION: Consider trying Google's Timezone API

paulsm4
  • 114,292
  • 17
  • 138
  • 190