Fix participant mails
authorJitendra Purohit <jitendra@fuzion.co.nz>
Thu, 20 Jul 2017 10:42:08 +0000 (16:12 +0530)
committerJitendra Purohit <jitendra@fuzion.co.nz>
Fri, 21 Jul 2017 11:40:24 +0000 (17:10 +0530)
CRM/Core/BAO/CustomField.php
tests/phpunit/CRM/Core/BAO/CustomQueryTest.php

index 3e74216e11b9c5d5f046d9d3999951c42e45ee33..4ce44b9d287ad4ff2a117d39944b0693a07c7869 100644 (file)
@@ -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);
           }
index 26629efcaf26fcfa67326cd75e733888072f2da2..2336be65b6704a9a78269b48806795600c6aa6e8 100644 (file)
@@ -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);
   }
 
   /**