Postgres timestamp with timezone support
Hi,
Is there any way or workaround to enable timestamp with timezone support for PostgreSQL databases?
I have been checking the code and adding this type to the adaptes seems not to be enough.
Thanks.
Can you give an example of the required definition, or syntax, that would allow this to work? I'm not sure I understand where the limitation is. Thanks!
Sure, between the data types for date/time supported by PgSQL (http://www.postgresql.org/docs/9.1/static/datatype-datetime.html) there are 2 different timestamps.
Timestamp without timezone (the one used when use the phinx timezone type) and with timezone which also stores the timezone related to the timestamp.
I didn't find a way to use the second.
Is using timestamptz or timestamp with time zone the more common practice in the Postgres community?
I can`t say if this is the most common practice but I helps a lot if you work with schedules and timezones, let's say that this is "the right way" to handle this type of issues because it let you abstract from more complex convertions.
I'm making a pull request with some little changes to add support and will link to this issue.
Thanks
Now supporting using the boolean timezone option for columns, which is only used by Postgres:
$table->addColumn('due_date', 'timestamp', array('timezone' => true));
If I want to work with DateTime? (not DateTimeTz).
The difference are in the "microseconds":
DateTime:
2016-08-04 14:34:34
DateTimeTz:
2016-08-04 14:34:34.367606
If I use:
$table->addColumn('due_date', 'timestamp', array('timezone' => true));
I get:
ADD COLUMN due_date timestamp without time zone
But, If I want DateTime (without microseconds) I must to do:
ADD COLUMN due_date timestamp(0) without time zone
But now way to do that with Phinx. Maybe if add the option "limit" in type "timestamp", this way I can add the numeric option in timestamp. eg:
$table->addColumn('due_date', 'timestamp', array('timezone' => true, 'limit' => 0));