title: How to make strtotime parse dates in Australian (i.e. UK) format: dd/mm/yyyy?
body: <p>I can't beleive I've never come across this one before.</p>
  
  <p>Basically, I'm parsing the text in human-created text documents and one of the fields I need to parse is a date and time. Because I'm in Australia, dates are formatted like <code>dd/mm/yyyy</code> but <code>strtotime</code> only wants to parse it as a US formatted date. Also, exploding by <code>/</code> isn't going to work because, as I mentioned, these documents are hand-typed and some of them take the form of <code>d M yy</code>.</p>
  
  <p>I've tried multiple combinations of <code>setlocale</code> but no matter what I try, the language is always set to US English.</p>
  
  <p>I'm fairly sure setlocale is the key here, but I don't seem to be able to strike upon the right code. Tried these:</p>
  
  <ul>
  <li>au</li>
  <li>au-en</li>
  <li>en_AU</li>
  <li>australia</li>
  <li>aus</li>
  </ul>
  
  <p>Anything else I can try?</p>
  
  <p>For clarity: I'm running on IIS with a Windows box.</p>
  
  <p>Thanks so much :)</p>
  
  <p>Iain</p>
  
  <p>Example:</p>
  
  <pre><code>$mydatetime = strtotime("9/02/10 2.00PM");
  echo date('j F Y H:i', $mydatetime);
  </code></pre>
  
  <p>Produces</p>
  
  <pre><code>2 September 2010 14:00
  </code></pre>
  
  <p>I want it to produce:</p>
  
  <pre><code>9 February 2010 14:00
  </code></pre>
  
  <hr>
  
  <p><strong>My solution</strong></p>
  
  <p>I'm giving the tick to one of the answers here as it is a much easier-to-read solution to mine, but here's what I've come up with:</p>
  
  <pre><code>$DateTime = "9/02/10 2.00PM";
  $USDateTime = preg_replace('%([0-3]?[0-9]{1})\s*?[\./ ]\s*?((?:1[0-2])|0?[0-9])\s*?[./ ]\s*?(\d{4}|\d{2})%', '${2}/${1}/${3}', $DateTime);  
  echo date('j F Y H:i',strtotime($USDateTime));
  </code></pre>
  
  <p>Because I can't rely on users to be consistent with their date entry, I've made my regex a bit more complex:</p>
  
  <ul>
  <li>0 or 1 digit between 0 and 3</li>
  <li>1 digit between 0 and 9 -- yes this will match 37 as a valid date but I think the regex is already big enough!</li>
  <li>Could be some whitespace</li>
  <li>Delimiting character (a '.', a '/' or a ' ')</li>
  <li>Could be some whitespace</li>
  <li>Either:
  
  <ul>
  <li>A number between 10 and 12 OR</li>
  <li>A number between 1 and 9 with an optional leading 0</li>
  </ul></li>
  <li>Could be some whitespace</li>
  <li>Delimiting character (a '.', a '/' or a ' ')</li>
  <li>Could be some whitespace</li>
  <li>Either:
  
  <ul>
  <li>A number 2 digits long OR</li>
  <li>A number 4 digits long</li>
  </ul></li>
  </ul>
  
  <p>Hopefully this will match most styles of date writing...</p>