We have just upgraded WP to 4.8.3 and Civi to 4.7.27, now getting the following error from one of our extensions:-

Call to undefined method CRM_Core_SelectValues::datePluginToPHPFormats()

The offending code snippet is below:-

protected function getFormattedFieldValue($value, $field) {
if ($field['data_type'] == 'Date' && !empty($value)) {
$actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
  $dateFormat = (array) CRM_Utils_Array::value($field['date_format'], $actualPHPFormats);
  $value = CRM_Utils_Date::processDate($value, NULL, FALSE, implode(" ", $dateFormat));
} elseif (!empty($field['option_group_id']) && $value) {
  try {
    $value = civicrm_api3('OptionValue', 'getvalue', array(
      'return' => 'label',
      'option_group_id' => $field['option_group_id'],
      'value' => $value,
  } catch (Exception $e) {
    throw $e;
return $value;


Any ideas how I can correct this code? I can't find the function in the docs: https://doc.symbiotic.coop/dev/civicrm/v47/phpdoc/CRM_Core_SelectValues.html

Thank you!


After searching on Jira for the funciton, nothing came up, so searched the codebase from our backup and found the function was in the file: civicrm/civicrm/CRM/Utils/Date.php:1788

It's now gone, along with a lot of other ones!

So I've added the array of date formats to the code to workaround the issue.

//$actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
  $actualPHPFormats = array(
    "mm/dd/yy" => 'm/d/Y',
    "dd/mm/yy" => 'd/m/Y',
    "yy-mm-dd" => 'Y-m-d',
    "dd-mm-yy" => 'd-m-Y',
    "dd.mm.yy" => 'd.m.Y',
    "M d" => 'M j',
    "M d, yy" => 'M j, Y',
    "d M yy" => 'j M Y',
    "MM d, yy" => 'F j, Y',
    "d MM yy" => 'j F Y',
    "DD, d MM yy" => 'l, j F Y',
    "mm/dd" => 'm/d',
    "dd-mm" => 'd-m',
    "yy-mm" => 'Y-m',
    "M yy" => 'M Y',
    "M Y" => 'M Y',
    "yy" => 'Y',

I can't find that function in the latest release so it seems to be fixed since 4.7.27 (latest is 5.0.0)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.