Can’t subtract offset-naive and offset-aware datetimes

I have a timezone aware timestamptz field in PostgreSQL. When I pull data from the table, I then want to subtract the time right now so I can get it’s age. The problem I’m having is that both datetime.datetime.now() and datetime.datetime.utcnow() seem to return timezone unaware timestamps, which results in me getting this error: TypeError: … Read more

How do I set the time zone of MySQL?

On one server, when I run: mysql> select now(); +———————+ | now() | +———————+ | 2009-05-30 16:54:29 | +———————+ 1 row in set (0.00 sec) On another server: mysql> select now(); +———————+ | now() | +———————+ | 2009-05-30 20:01:43 | +———————+ 1 row in set (0.00 sec) 23 Answers 23

How do I get a value of datetime.today() in Python that is “timezone aware”?

I am trying to subtract one date value from the value of datetime.datetime.today() to calculate how long ago something was. But it complains: TypeError: can’t subtract offset-naive and offset-aware datetimes The return value from datetime.datetime.today() doesn’t seem to be “timezone aware”, while my other date value is. How do I get a return value from … Read more

MySQL JDBC Driver 5.1.33 – Time Zone Issue

Some background: I have a Java 1.6 webapp running on Tomcat 7. The database is MySQL 5.5. Previously, I was using Mysql JDBC driver 5.1.23 to connect to the DB. Everything worked. I recently upgraded to Mysql JDBC driver 5.1.33. After the upgrade, Tomcat would throw this error when starting the app. WARNING: Unexpected exception … Read more

Create a Date with a set timezone without using a string representation

I have a web page with three dropdowns for day, month and year. If I use the JavaScript Date constructor that takes numbers, then I get a Date object for my current timezone: new Date(xiYear, xiMonth, xiDate) Give the correct date, but it thinks that date is GMT+01:00 due to daylight savings time. The problem … Read more