I write a Drupal7 module which allows CiviCRM event registration form design alter. While getting a list of events from CiviCRM, the module performs some checks against events properties.


  /* Get today in PHP  */
  $dt = new DateTime();
  $now = $dt->format('Y-m-d');

 $event_arr = civicrm_api3('Event', 'get', array(
'is_active' => 1,
'is_online_registration' => 1,
'return' => array("id", "title"),
'is_template' => 0,
  /* FTW??? */'event_registration_end_date' => array('>=' => $now),



There are two websites with different locales, hence different default date formats (Y-m-d and Y-d-m) and one of this gives "Fatal error: Unsupported operand types " ( perhaps because of date in a wrong format, if it's not an API error).


How to get "today" in CiviCRM default date format (defined in /civicrm/admin/setting/date?reset=1) in Drupal module


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.