datetime and timezone conversion with pytz – mind blowing behaviour

The documentation http://pytz.sourceforge.net/ states “Unfortunately using the tzinfo argument of the standard datetime constructors ‘does not work’ with pytz for many timezones.” The code: t = datetime( 2013, 5, 11, hour=11, minute=0, tzinfo=pytz.timezone(‘Europe/Warsaw’) ) doesn’t work according to this, instead you should use the localize method: t = pytz.timezone(‘Europe/Warsaw’).localize( datetime(2013, 5, 11, hour=11, minute=0))

Why does Heroku log using the server time rather than the Rails time zone?

After some further investigation into my own Heroku timezone problems, I found a post which indicates that you actually can specify the timezone at an application level, using the following command: heroku config:add TZ=Europe/Oslo I believe this may be the answer to all your troubles. Courtesy of http://www.reality.hk/articles/2010/01/07/1319/ (Edit: Broken link as of 2012.08.23. Archived … Read more

Rails: how get current time zone compatible with ActiveSupport::TimeZone[zone].parse()?

Use Time.zone.name, not Time.zone.to_s [1] pry(main)> Time.zone.to_s => “(GMT-05:00) Eastern Time (US & Canada)” [2] pry(main)> Time.zone.name => “Eastern Time (US & Canada)” [3] pry(main)> ActiveSupport::TimeZone[Time.zone.name] => (GMT-05:00) Eastern Time (US & Canada) As for how I got this (as requested), I just know the name method exists on Time.zone. If I didn’t know this … Read more

convert epoch time to date

EDIT: Okay, so you don’t want your local time (which isn’t Australia) to contribute to the result, but instead the Australian time zone. Your existing code should be absolutely fine then, although Sydney is currently UTC+11, not UTC+10.. Short but complete test app: import java.util.*; import java.text.*; public class Test { public static void main(String[] … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)