Answers.Body: <p>I'm not sure this is possible in Twig alone, but it should be easy enough in PHP.</p>
  
  <p>To do that, you could write a Craft <a href="http://buildwithcraft.com/docs/plugins/introduction" rel="nofollow">plugin</a> that adds a custom Twig extension that has a ScormIt filter that uses PHP's <a href="http://php.net/manual/en/dateinterval.construct.php" rel="nofollow">DateInterval</a> class to output it in the format that you're looking for.</p>
  
  <p>That way, you could do something like:</p>
  
  <pre><code>{{ videoObject.duration|ScormIt }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-03T18:19:07.113Z
Answers.Text: Thanks Brad. Might be a good reason to get into writing a plugin. Seems feasible, even for me. :)
Answers.UserDisplayName: Marcus Scheller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-03T18:23:58.517Z
Answers.Text: If @low can do it, anyone can. You can use his RegEx twig filter as a starting point: https://github.com/low/low_regex
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-03T17:41:10.917Z
Answers.LastActivityDate: 2014-10-03T18:08:23.067Z
Answers.LastEditDate: 2014-10-03T18:08:23.067Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a video Object with a duration property formatted in <a href="http://www.ostyn.com/standards/scorm/samples/ISOTimeForSCORM.htm" rel="nofollow">SCORM 2004 time format</a>. Like so: <strong>PT51M55S</strong>. How do i convert this into a human readable time format like: <strong>51:55</strong>? <code>date()</code> does not seem to work obviously.</p>
  
Tags: <templating><datetime><format><conversion>
Title: Twig: Convert time format
ThreadText: # Twig: Convert time format
  
  (Asked by: username_0 on 2014-10-03)
  
  I have a video Object with a duration property formatted in [SCORM 2004 time format](http://www.ostyn.com/standards/scorm/samples/ISOTimeForSCORM.htm). Like so: **PT51M55S**. How do i convert this into a human readable time format like: **51:55**? `date()` does not seem to work obviously.
  
  **Tags:** templating, datetime, format, conversion
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-03. Score: 2
  
  I'm not sure this is possible in Twig alone, but it should be easy enough in PHP.
  
  To do that, you could write a Craft [plugin](http://buildwithcraft.com/docs/plugins/introduction) that adds a custom Twig extension that has a ScormIt filter that uses PHP's [DateInterval](http://php.net/manual/en/dateinterval.construct.php) class to output it in the format that you're looking for.
  
  That way, you could do something like:
  
  ```
  {{ videoObject.duration|ScormIt }}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_1. Might be a good reason to get into writing a plugin. Seems feasible, even for me. :)  
  > **username_1**: If @low can do it, anyone can. You can use his RegEx twig filter as a starting point: https://github.com/low/low_regex  
  
  ---
  
  