title: Why I have this error trying to use the JavaScript substr() function?
body: <p>I am absolutly new in JavaScript and I have the following problem trying to use the <strong>substr()</strong> method.</p>
  
  <p>I have a string that represent a data: 20141202 (that is for 2014-12-02 without the '-' character).</p>
  
  <p>So my <strong>DataDA</strong> variable contains the value <strong>20141202</strong></p>
  
  <p>Now I want to extract the <strong>year</strong>, the <strong>month</strong> and the <strong>day</strong> from this string and I have done something like this:</p>
  
  <pre><code>year = DataDA.substr(0,4); 
  </code></pre>
  
  <p>and this seems work fine because year value is <strong>2014</strong></p>
  
  <p>But when I try to extract the month I have a very strange behavior, infact I do:</p>
  
  <pre><code>month = DataDA.substr(5,6); 
  </code></pre>
  
  <p>and instead obtain <strong>12</strong> I obtain <strong>202</strong></p>
  
  <p>Why? What am I missing?</p>