title: How can i change date format to British in JavaScript
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3117262/javascript-date-objects-uk-dates">JavaScript date objects UK dates</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following code and I am having problem setting the date format to british i.e </p>
  
  <pre><code>var birthday = new Date("20/9/1988"); 
  </code></pre>
  
  <p>when I run the code I get <code>You are NaN years old</code>. error but If i change it to say 09/20.1988 it works</p>
  
  <pre><code>var birthday = new Date("20/9/1988");
  var today = new Date();
  var years = today.getFullYear() - birthday.getFullYear();
  
  // Reset birthday to the current year.
  birthday.setFullYear(today.getFullYear());
  
  // If the user's birthday has not occurred yet this year, subtract 1.
  if (today &lt; birthday)
  {
      years--;
  }
  document.write("You are " + years + " years old.");
  
  // Output: You are years years old.
  </code></pre>