Reputation: 2535
I have an asp.net website that will be hosted on a server using EST time and will likely be made on a computer/device operating in EST. The user will be making updates to information pertaining to locations all over North America. I need the timestamp of the update to be made in the local time of the location that the update is being made to, not server or computer time. So I need to be able to get the offset for a location based on either City and State/Province or the Zip code. I've already looked at http://www.earthtools.org/webservices.htm#timezone and it requires latitude and longitude, which I don't have.
Upvotes: 0
Views: 2066
Reputation: 62260
You can retireve Latitude and Longitude from Google map.
For example, address is '123 Street, Los Angeles, CA 12345' or address is zip code only '12346'
public void GetCoordinate(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(String.Format("http://maps.google.com/maps/geo?output=csv&q=" + HttpUtility.UrlEncode(address)));
// Return numbers -
// 1 = Status Code
// 2 = Accurancy
// 3 = Latitude
// 4 = Longitude
string[] geocodeInfo = client.DownloadString(uri).Split(',');
decimal latitude = Convert.ToDecimal(geocodeInfo[2]);
decimal longitude = Convert.ToDecimal(geocodeInfo[3]);
}
I suggest save the created/updated time in UTC. When you display it, convert that UTC to user's local time based on the user's time zone offset (which is saved in the user's profile).
Upvotes: 1