Using current time in UTC as default value in PostgreSQL

I have a column of the TIMESTAMP WITHOUT TIME ZONE type and would like to have that default to the current time in UTC. Getting the current time in UTC is easy: postgres=# select now() at time zone ‘utc’; timezone —————————- 2013-05-17 12:52:51.337466 (1 row) As is using the current timestamp for a column: postgres=# … Read more

How do I get the current time zone of MySQL?

Anyone knows if there is such a function in MySQL? UPDATE This doesn’t output any valid info: mysql> SELECT @@global.time_zone, @@session.time_zone; +——————–+———————+ | @@global.time_zone | @@session.time_zone | +——————–+———————+ | SYSTEM | SYSTEM | +——————–+———————+ Or maybe MySQL itself can’t know exactly the time_zone used,that’s fine, we can involve PHP here, as long as I can … Read more

How to convert a UTC datetime to a local datetime using only standard library?

I have a python datetime instance that was created using datetime.utcnow() and persisted in database. For display, I would like to convert the datetime instance retrieved from the database to local datetime using the default local timezone (i.e., as if the datetime was created using datetime.now()). How can I convert the UTC datetime to a … Read more

“date(): It is not safe to rely on the system’s timezone settings…”

I got this error when I requested to update the PHP version from 5.2.17 to PHP 5.3.21 on the server. <div style=”border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;”> <h4>A PHP Error was encountered</h4> <p>Severity: Warning</p> <p>Message: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting … Read more

How to get a time zone from a location using latitude and longitude coordinates?

Given the latitude and longitude of a location, how does one know what time zone is in effect in that location? In most cases, we are looking for an IANA/Olson time zone id, although some services may return just a UTC offset, or some other time zone identifier. Please read the timezone tag info for … Read more