Answers.Body: <p>I am not sure if this is possible through UI configuration. The form only allows you to enter valid date but not now(), CURRENT_DATE() etc. However it is definitely possible by adding a small code in a extension.</p>
  
  <ol>
  <li>Create and enable a new CiviCRM extension</li>
  <li>Implement the hook_civicrm_buildForm in your extension</li>
  </ol>
  
  <p>For the appropriate variable do:</p>
  
  <pre><code>function ext_civicrm_buildForm($formName, &amp;$form) {
    if ($formName == 'REPLACE_WITH_FORMNAME') {
      $defaultDate = [];
      CRM_Utils_Date::getAllDefaultValues($defaultDate);
      $defaults['custom_XXX'] = $defaultDate;
      $form-&gt;setDefaults($defaults);
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-06T22:30:13.123Z
Answers.Text: Thanks, but in what file do I input this code? What exact path?
Answers.UserDisplayName: Bruno  Vincent
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-06T23:09:24.060Z
Answers.Text: You will need to create a extension using Civix and then implement the hook.
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-07T00:25:27.110Z
Answers.Text: That sounds a little complicated...when I create a contact, on the bottom of the form is says: "Last Change by: Bruno Vincent (September 11th, 2018 4:43 PM)  » " , now what I would like is a filed that shows up in views displaying a datecreated field, how could I do that?
Answers.UserDisplayName: Bruno  Vincent
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-18T16:51:55.080Z
Answers.Text: I am getting error on civi 5.65, is this still functional ? @PradeepNayak-CircleInt.
Answers.UserDisplayName: Tapash
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-19T14:42:49.870Z
Answers.Text: Nope, that's just the snippet
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-06T11:28:46.547Z
Answers.LastActivityDate: 2018-10-06T11:28:46.547Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>The threads I have seen are from 2009...</p>
  
  <p>Is there a solution for this in 2018?</p>
  
  <p>Something that would dynamically set current date as default?</p>
  
  <p><a href="https://i.sstatic.net/YJP9C.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/YJP9C.png" alt="enter image description here"></a></p>
  
Tags: <dates>
Title: How can I set custom field date field for default date to be today's date?
ThreadText: # How can I set custom field date field for default date to be today's date?
  
  (Asked by: username_0 on 2018-10-06)
  
  The threads I have seen are from 2009...
  
  Is there a solution for this in 2018?
  
  Something that would dynamically set current date as default?
  
  [![enter image description here](https://i.sstatic.net/YJP9C.png)](https://i.sstatic.net/YJP9C.png)
  
  **Tags:** dates
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-06. Score: 1
  
  I am not sure if this is possible through UI configuration. The form only allows you to enter valid date but not now(), CURRENT_DATE() etc. However it is definitely possible by adding a small code in a extension.
  
  Create and enable a new CiviCRM extension
  Implement the hook_civicrm_buildForm in your extension
  
  For the appropriate variable do:
  function ext_civicrm_buildForm($formName, &$form) {
    if ($formName == 'REPLACE_WITH_FORMNAME') {
      $defaultDate = [];
      CRM_Utils_Date::getAllDefaultValues($defaultDate);
      $defaults['custom_XXX'] = $defaultDate;
      $form->setDefaults($defaults);
    }
  }
  
  > **Comments:**
  > **username_0**: Thanks, but in what file do I input this code? What exact path?  
  > **username_1**: You will need to create a extension using Civix and then implement the hook.  
  > **username_0**: That sounds a little complicated...when I create a contact, on the bottom of the form is says: "Last Change by: Bruno Vincent (September 11th, 2018 4:43 PM)  » " , now what I would like is a filed that shows up in views displaying a datecreated field, how could I do that?  
  > **username_2**: I am getting error on civi 5.65, is this still functional ? @PradeepNayak-CircleInt.  
  > **username_1**: Nope, that's just the snippet  
  
  ---
  
  