Postgres timezone without microseconds
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4.5k
- Forks
- 884
- PR merge metrics
- No merged PRs in 30d
Description
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));
Postgres has a variable return format for the datatype TIMESTAMP(n) and TIME(n) if microseconds are allowed (n > 0). Whenever you save a value with microseconds = 0. PostgreSQL will return this value in the format:
2010-10-10 10:10:10 (Y-m-d H:i:s)
However if you save a value with microseconds it will return the full representation:
2010-10-10 10:10:10.123456 (Y-m-d H:i:s.u)
Using the DateTime, DateTimeTz or Time type with microseconds enabled columns can lead to errors because internally types expect the exact format ‘Y-m-d H:i:s’ in combination with DateTime::createFromFormat(). This method is twice a fast as passing the date to the constructor of DateTime.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the addColumn('due_date', 'timestamp', array('timezone' => true)) entry point and trace how PostgreSQL emits timestamp column definitions. Check the DateTime, DateTimeTz, and Time handling described in the issue. Done means timestamp precision can be specified for PostgreSQL, including timestamp(0) without time zone, without causing date parsing errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, postgresql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100