/ Published in: PHP
Expand |
Embed | Plain Text
/** * Implements hook_views_query_alter * - If the db doesn't have timezone support transform exposed filter date inputs from the sites default timezone to UTC. * @TODO - can the conversion to UTC happen somewhere in the $view->handler, hook_form_alter, or date api */ function mymodule_views_query_alter(&$view, &$query) { $tz = variable_get('date_default_timezone_name', 'Pacific/Auckland'); date_default_timezone_set('UTC'); $dates = &$query->where['date']['clauses']; foreach($dates as &$date) { '(\d{4}-\d{2}-\d{2})', $date ); } date_default_timezone_set($tz); } }
You need to login to post a comment.
