timezone

Guessing the time zone from an arbitrary "location" string?

I'm trying to run some statistics over the Stack Overflow data dump, and for that I would like to know the time zone for each user. However, all I have to go on is the completely free-form "location" string. I'll stress that I'm only looking for an approximation of the time zone; of course, in general this is an unsolvable problem. Howe...

"date_part('epoch', now() at time zone 'UTC')" not the same time as "now() at time zone 'UTC'" in postgresql

I'm writing a web based front end to a database (PHP/Postgresql) in which I need to store various dates/times. The times are meant to be always be entered on the client side in the local time, and displayed in the local time too. For storage purposes, I store all dates/times as integers (UNIX timestamps) and normalised to UTC. One partic...

TimeZoneInfo vs. Olson database

Do TimeZoneInfo and Olson database use identical identificators for time zones? I get timezone id from GeoNames service (which is based on Olson database) and want to retrieve day light saving information for that timezone. ...

Best way to get timezone of user based on area code

Hi folks I'm attempting to get a timezone of a user based on area code information that they provided. I discovered the following resource on maxmind: http://geolite.maxmind.com/download/geoip/api/php/timezone/ I suspect that I could use this with another api that provides the state that an area code belongs to. I'm looking for a si...

Force Java timezone as GMT/UTC

Hi. I need to force any time related operations to GMT/UTC, regardless the timezone set on the machine. Any convenient way to so in code? To clarify, I'm using the DB server time for all operations, but it comes out formatted according to local timezone. Thanks! ...

How to determine the timezone that an email was sent from in C#

Can anyone recommend a way to determine the timezone that an email was sent from in C#? Looking at the header information of an email includes information like: Received: from mail-ew0-f211.google.com (123.85.219.211) by UKExchange (10.1.10.99) with Microsoft SMTP Server id 1.2.345.6; Tue, 13 Apr 2010 14:26:24 +0100 Received: by ewy3...

How do I elegantly print the %z (timezone) format in Perl on Windows?

An offshoot of http://stackoverflow.com/questions/172110/how-do-i-elegantly-print-the-date-in-rfc822-format-in-perl, but Windows specific. On windows: C:\> perl -MPOSIX print strftime('%z', localtime()),"\n"; Yields: Central Daylight Time I was expecting: -0500 As anyone would on a Linux system. How can I get th...

free web service returning city names, city codes and time zone

Do you know a web service that's able let's say get a full list of cities in the world with names, short names like PAR for Paris and time zones? Or at least query by city name: Paris -> timezone=+02:00, abbrev=PAR Also, what I see here: http://www.earthtools.org/webservices.htm#timezone offset The number of hours offset from UTC dis...

Java TimeZones: how to get UTC time values based on Console settings?

For example, when I extract from a database a Date() variable, it contains a date with "+04:00" shift. According to my locale's settings. So, UTC time is "ourTime" MINUS 4 hours. Then, a user tells where he/she is from. Now, we need to save his/her shift. LET'S SAY it is -01:00. And finally, this user tells us where's he/she is headin...

Safely convert UTC datetimes to local time (based on TZ) for calculations?

Following from my last question which @Jon Skeet gave me a lot of help with (thanks again!) I am now wondering how I can safely work with date/times, stored as UTC, when they are converted back to Local Date/Time. As Jon indicated in my last question using DateTimeOffset represents an instant in time and there is no way to predict wha...

How to get #entries of last hour in MySQL, correcting for timezone?

I am storing activity entries in a MySQL table. The table has a date_created field of type timestamp and through PHP I insert the activity entries based on GMT: $timestamp = gmdate("Y-m-d H:i:s", time()); This works fine. On my client I am on GMT+2. If it is 16:00 here and I insert an entry, it is stored in MySQL as 14:00. This is as ...

Python datetime not including DST when using pytz timezone

If I convert a UTC datetime to swedish format, summertime is included (CEST). However, while creating a datetime with sweden as the timezone, it gets CET instead of CEST. Why is this? >>> # Modified for readability >>> import pytz >>> import datetime >>> sweden = pytz.timezone('Europe/Stockholm') >>> >>> datetime.datetime(2010, 4, 20, 1...

PHP Timezone problem

I am in Albuquerque, NM. I am trying to update some stamps every time I put an entry into a database. Here is what I use. date_default_timezone_set("US/Mountain"); $stamp =mktime(); //$stamp = gmmktime(); $time = date("H:i:s",$stamp);$date = date("Y-m-d",$stamp); My local time is 12:15 PM but what I get is 18:15PM instead. If you...

How can I get and use a user's TZ setting from their .bashrc in a Perl CGI script?

Each of my users has a (possibly) different TZ defined in their .bashrc. I have a Perl script that displays date/time and want it to have it display with their profile time zone. Does anyone know the best way to do this? ...

TimeZone#setDefault() on application server with JDK 1.6

What happens if #setDefault(TimeZone timezone) is called by a concurrent application running on the same application server with JDK 1.6 As discussed in TimeZone #setDefault changes in JDK 6 the call now changes VM wide, this can have horrible consequences. If you're not adminsitrating the application server, how to ensure TimeZone doe...

Mysql: Convert DB from local time to UTC

I need to convert an existing (datetime fields) db from local time ut UTC. The values are stored ad datetimes on a server with time zone CET (+1) (with summertime +2). When selecting data I use UNIX_TIMESTAMP(), which magically compensates for everything, ie, time zone shift and dst (if i've read the docs right). I'm moving the db to a...

Adding time zone hours difference to time

I know there's a much better and correct way to do it, but i need a temporarily solutions. I need to add in extra hours to the time, and the day will change automatically too. How should I change the code below? package { public class getTime { private var today:Date=new Date(); private var hour:uint=today.getHours(); privat...

Drupal timezone information

In my drupal installation I can get the offset from UTC in seconds to the timezone I specified in the admin panel using variable_get('date_default_timezone', 0) However, now that we have daylight-saving-time, the time I get is always off by one hour. Is there a way to retrieve the actual timezone string from Drupal, as "Europe/Berlin...

heroku time zone problem, logging local server time

UPDATE: Ok, I didn't formulate a good Q to be answered. I still struggle with heroku being on -07:00 UTC and I at +02:200 UTC. Q: How do I get the log written in the correct Time.zone ? The 9 hours difference, heroku (us west) - norway, is distracting to work with. I get this in my production.log (using heroku logs): Processing Pro...

Python: Figure out local timezone

I want to compare UTC timestamps from a log file with local timestamps. When creating the local datetime object, I use something like: >>> local_time=datetime.datetime(2010, 4, 27, 12, 0, 0, 0, tzinfo=pytz.timezone('Israel')) I want to find an automatic tool that would replace thetzinfo=pytz.timezone(...