Convert pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone

To answer my own question, this functionality has been added to pandas in the meantime. Starting from pandas 0.15.0, you can use tz_localize(None) to remove the timezone resulting in local time. See the whatsnew entry: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#timezone-handling-improvements So with my example from above: In [4]: t = pd.date_range(start=”2013-05-18 12:00:00″, periods=2, freq=’H’, tz= “Europe/Brussels”) In [5]: t … Read more

How to detect user’s timezone?

To summarize Matt Johnson’s answer in terms of code: <script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js”> </script> <script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js”> </script> <script type=”text/javascript”> $(document).ready(function(){ var tz = jstz.determine(); // Determines the time zone of the browser client var timezone = tz.name(); //For e.g.:”Asia/Kolkata” for the Indian Time. $.post(“url-to-function-that-handles-time-zone”, {tz: timezone}, function(data) { //Preocess the timezone in the controller function … Read more

get user timezone [duplicate]

This will get you the timezone as a PHP variable. I wrote a function using jQuery and PHP. This is tested, and does work! On the PHP page where you are want to have the timezone as a variable, have this snippet of code somewhere near the top of the page: <?php session_start(); $timezone = … Read more

Creating a DateTime in a specific Time Zone in c#

Jon’s answer talks about TimeZone, but I’d suggest using TimeZoneInfo instead. Personally I like keeping things in UTC where possible (at least for the past; storing UTC for the future has potential issues), so I’d suggest a structure like this: public struct DateTimeWithZone { private readonly DateTime utcDateTime; private readonly TimeZoneInfo timeZone; public DateTimeWithZone(DateTime dateTime, … Read more

Timezone conversion

tl;dr ZonedDateTime.now( ZoneId.of( “Pacific/Auckland” )) // Current moment in a particular time zone. .withZoneSameInstant( ZoneId.of( “Asia/Kolkata” )) // Same moment adjusted into another time zone. Details The java.util.Date class has no time zone assigned†, yet it’s toString implementation confusingly applies the JVM’s current default time zone. Avoid java.util.Date & .Calendar This is one of many … Read more

How to preserve timezone when parsing date/time strings with strptime()?

I recommend using python-dateutil. Its parser has been able to parse every date format I’ve thrown at it so far. >>> from dateutil import parser >>> parser.parse(“Tue Jun 22 07:46:22 EST 2010”) datetime.datetime(2010, 6, 22, 7, 46, 22, tzinfo=tzlocal()) >>> parser.parse(“Fri, 11 Nov 2011 03:18:09 -0400”) datetime.datetime(2011, 11, 11, 3, 18, 9, tzinfo=tzoffset(None, -14400)) >>> … Read more