3

Preamble

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.

Code

  /* 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),

));

Problem

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).

Question

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

Thanks!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.