From c65ec4564f07f7f84b7a13047a8bbed58ab294e5 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Thu, 20 Jul 2017 16:12:08 +0530 Subject: [PATCH] Fix participant mails --- CRM/Core/BAO/CustomField.php | 4 ++-- tests/phpunit/CRM/Core/BAO/CustomQueryTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 3e74216e11..4ce44b9d28 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1234,8 +1234,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { break; default: - // if time is not selected remove time from value - $value = substr($value, 0, 10); + //If time is not selected remove time from value. + $value = $value ? date('Y-m-d', strtotime($value)) : ''; } $customFormat = implode(" ", $customTimeFormat); } diff --git a/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php b/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php index 26629efcaf..2336be65b6 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomQueryTest.php @@ -81,6 +81,10 @@ class CRM_Core_BAO_CustomQueryTest extends CiviUnitTestCase { $queryObj->_where[0][0] ); $this->assertEquals($queryObj->_qill[0][0], "date field BETWEEN 'June 6th, 2014 12:00 AM AND June 6th, 2015 11:59 PM'"); + + //CRM-17236 - Test custom date is correctly displayed without time. + $formattedValue = CRM_Core_BAO_CustomField::displayValue(date('Ymdhms'), $dateCustomField['id']); + $this->assertEquals(date('m/d/Y'), $formattedValue); } /** -- 2.25.1