Answers.Body: <p>Generally speaking, only <a href="https://craftcms.com/classreference#craft.app.variables" rel="nofollow">Variable</a> classes are exposed to templates in Craft and there isn't a Variable wrapper for <a href="https://craftcms.com/classreference/helpers/DateTimeHelper" rel="nofollow">DateTimeHelper</a>.</p>
  
  <p>However, that would be a super-simple <a href="https://craftcms.com/docs/plugins/introduction" rel="nofollow">plugin</a> to write that exposes <code>timeAgoInWords</code> as a Twig <a href="http://twig.sensiolabs.org/documentation" rel="nofollow">filter</a> so you could do something like</p>
  
  <pre><code>entry.postDate|timeAgoInWords
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-31T18:06:09.110Z
Answers.LastActivityDate: 2015-12-31T18:06:09.110Z
Answers.UserDisplayName: Brad Bell
Body: <p>Not quite sure how to use functions defined in Helper classes in my templates. For example, trying to use "timeAgoInWords" on an entry's dateCreated attribute. I get an internal server error and a "Unknown "timeAgoInWords" function" message when I try to visit the page. It occurs to me that perhaps I have to include or import the DateTimeHelper class? I'm not sure how to go about this.</p>
  
  <p>Here's a link to the Craft docs on the package that I'm trying to include:</p>
  
  <p><a href="https://craftcms.com/classreference/helpers/DateTimeHelper" rel="nofollow">https://craftcms.com/classreference/helpers/DateTimeHelper</a></p>
  
  <p>I'm trying to include the timeAgoInWords function in my index.html template within the templates folder.</p>
  
  <p>Thanks a bunch!</p>
  
Tags: <error>
Title: Issue trying to use function from DateTimeHelper class: "timeAgoInWords() is not defined"
ThreadText: # Issue trying to use function from DateTimeHelper class: "timeAgoInWords() is not defined"
  
  (Asked by: username_0 on 2015-12-31)
  
  Not quite sure how to use functions defined in Helper classes in my templates. For example, trying to use "timeAgoInWords" on an entry's dateCreated attribute. I get an internal server error and a "Unknown "timeAgoInWords" function" message when I try to visit the page. It occurs to me that perhaps I have to include or import the DateTimeHelper class? I'm not sure how to go about this.
  
  Here's a link to the Craft docs on the package that I'm trying to include:
  
  <https://craftcms.com/classreference/helpers/DateTimeHelper>
  
  I'm trying to include the timeAgoInWords function in my index.html template within the templates folder.
  
  Thanks a bunch!
  
  **Tags:** error
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-12-31. Score: 3 | Accepted answer
  
  Generally speaking, only [Variable](https://craftcms.com/classreference#craft.app.variables) classes are exposed to templates in Craft and there isn't a Variable wrapper for [DateTimeHelper](https://craftcms.com/classreference/helpers/DateTimeHelper).
  
  However, that would be a super-simple [plugin](https://craftcms.com/docs/plugins/introduction) to write that exposes `timeAgoInWords` as a Twig [filter](http://twig.sensiolabs.org/documentation) so you could do something like
  
  ```
  entry.postDate|timeAgoInWords
  
  ```
  
  
  ---
  
  