[wp-trac] [WordPress Trac] #48740: Add constant for database date format

WordPress Trac noreply at wordpress.org
Wed Nov 20 14:05:39 UTC 2019


#48740: Add constant for database date format
--------------------------------------+------------------------------
 Reporter:  Rarst                     |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Date/Time                 |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  needs-patch dev-feedback  |     Focuses:
--------------------------------------+------------------------------

Comment (by remcotolsma):

 I have developed custom WordPress solutions that used `DATE` and
 `DATETIME(6)` types in custom database tables. I don't think WordPress is
 using these MySQL types currently. But the name `WP_DATE_MYSQL` could be
 confusing, for me it makes more sense that that constant contains the
 `'Y-m-d'` notation. Could be improved by using something like this:

 - `define( 'WP_DATE_MYSQL_DATE', 'Y-m-d' );`
 - `define( 'WP_DATE_MYSQL_DATETIME', 'Y-m-d H:i:s' );`
 - `define( 'WP_DATE_MYSQL_DATETIME_6', 'Y-m-d H:i:s.u' );`

 > but `WP_DATE_DATABASE` might be more appropriately generic.

 Maybe other database systems do accept a ISO 8601 date in queries?

 - https://dev.mysql.com/doc/refman/8.0/en/datetime.html
 - https://github.com/php/php-src/pull/3690

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48740#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list