title: Javascript Extract t Time parameters from Youtube URLs
body: <p>I search a way to extract the t time parameters content </p>
  
  <p>So , for example :</p>
  
  <pre><code>https://youtu.be/YykjpeuMNEk?t=2m3s
  https://youtu.be/YykjpeuMNEk?t=3s
  https://youtu.be/YykjpeuMNEk?t=1h2m3s
  </code></pre>
  
  <p>I'd like to get the h,m and s values.</p>
  
  <p>I can image i have to use RegEx in order to make the work, but i'm cannot find the right expression string (little novice in that point)</p>
  
  <p>I just have this for the moment :</p>
  
  <pre><code>var matches = t.match(/[0-9]+/g);
  </code></pre>
  
  <p>i use this tool to test different expressions, but unable to format it correctly and be sure that the content is exactly related to h,m and s.</p>
  
  <p>If you have any idea ;)</p>
  
  <p><strong>ANSWER THAT WORKS FOR ME</strong> :</p>
  
  <pre><code>url = 'https://youtu.be/vTs7KXqZRmA?t=2m18s';
  var matches = url.match(/\?t=(?:(\d+)h)?(?:(\d+)m)?(\d+)s/i);
  var s = 0;
  s += matches[1] == undefined ? 0 : (Number(matches[1])*60*60);
  s += matches[2] == undefined ? 0 : (Number(matches[2])*60);
  s += matches[3] == undefined ? 0 : (Number(matches[3]));
  console.log(s);
  </code></pre>
  
  <p>output :</p>
  
  <pre><code>138
  </code></pre>
  
  <p>thanks to all ;)</p>