2

I've added a date and time field to an activity ('departure date'). The problem is that it steadfastly refuses to display as anything other than YYYY-MM-DD HH-MM-SS even though the custom field is specified as d MM yy with a 12 hour time format. This is when I hit 'View' against an activity in a list of case activities and get a pop up. Which does look odd when the activity date is displayed correctly as (e.g.) 14 June, 2021 1:03pm. My 'date preferences' were all set to default (I'm in the UK) but to try and fix this this I've set the 2 activity dates formats to d MM yy, and the custome the same. But to no avail. Civi is at 5.37.2 - I guess a bug? Problem raised as this issue

7
  • display 'where'?
    – petednz - fuzion
    Commented Jun 14, 2021 at 20:26
  • only asking as there is an outstanding issue of time/date not displaying in specified format in eg receipts
    – petednz - fuzion
    Commented Jun 14, 2021 at 20:26
  • Edited the question & added 'This is when I hit 'View' against an activity in a list of case activities & get a pop up'
    – Andy Clark
    Commented Jun 14, 2021 at 20:31
  • I can see the same problem on other activity types too where there is a custom date field. The activity date shows up as d MM y but the custom date is dd/mm/yyy (where there is no time field)
    – Andy Clark
    Commented Jun 14, 2021 at 20:38
  • 1
    I see the same thing just haven't noticed since my date setting actually is yyyy-mm-dd. I'd post a lab ticket.
    – Demerit
    Commented Jun 15, 2021 at 15:02

1 Answer 1

1

This is specific to civicase activities and it's because the view form uses its own way of displaying custom fields that's different from regular activities. I posted this quickie patch in the lab ticket but it's not the best long-term solution:

diff --git a/templates/CRM/Case/Form/ActivityView.tpl b/templates/CRM/Case/Form/ActivityView.tpl
index 9bc3c3d781..868c69c512 100644
--- a/templates/CRM/Case/Form/ActivityView.tpl
+++ b/templates/CRM/Case/Form/ActivityView.tpl
@@ -54,7 +54,11 @@
             {foreach from=$customGroup item=customField name=fields}
               <tr{if ! $smarty.foreach.fields.last} style="border-bottom: 1px solid #F6F6F6;"{/if}>
                 <td class="label">{$customField.label}</td>
+                {if $customField.type == 'Date'}
+                <td>{$customField.value|crmDate}</td>
+                {else}
                 <td>{$customField.value}</td>
+                {/if}
               </tr>
             {/foreach}
           {/foreach}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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