I have a table that has DATETIME fields, but for some reason this module is expecting the fields to be a Unix epoch number, rather than the ISO string that it actually is.
Is there a simple way around this?
I have a table that has DATETIME fields, but for some reason this module is expecting the fields to be a Unix epoch number, rather than the ISO string that it actually is.
Is there a simple way around this?
Comments
Comment #1
dave kopecekSame question here.
Comment #2
patcon commentedI'm working along a similar things in:
#950020: How to get an array of all handlers
#703864-1: date_api_filter_handler can't find what views_handler_filter_date can see
Only core handlers are options by default in Data module. This shouldn't be an issue for the field handler, since I believe date api automatically takes over for
views_handler_field_date(this isn't the case for the core date FILTER handler, and I'll explain that below). But anyhow, even though date api can take over, unless otherwise indicated, it assumes UNIX time.If you have an ISO time or whatever, you'll need to define your date field in a custom module with
HOOK_date_api_fields(), or else drupal won't know the format of your date (core otherwise assumes UNIX). This is done automatically for CCK fields, but if you're just working with a simple database table, drupal doesn't know.Just copy this format for your own function:
http://api.lullabot.com/date_api_date_api_fields
And if it comes time to try to assign a filter for your date from the Data module UI, you need to use
drupal_data_views_handlers_alter($handlers)to add thedate_api_filter_handler, since onlyviews_handler_filter_dateis available by default in the UI. You can see where thisdrupal_alter()function is created indata.views.inc, so you can check out how it expects$handlersto be formatted.Does this get at what you needed?
Comment #3
arski commentedwhat about when one is creating a table through the Data interface? Any chance to add date field option there?
Thanks
Comment #4
joachim commentedWorks on D7. Unlikely to be ported to D6.